# index-of-x

> An extended ES6 indexOf.

Latest version **3.1.2** (published 2019-08-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install index-of-x
pnpm add index-of-x
yarn add index-of-x
bun add index-of-x
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.1.2 |
| Published | 2019-08-28 |
| First published | 2015-11-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=8.11.4 |
| Dependencies | 13 |
| Unpacked size | 326.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Graham Fairweather |
| Maintainers | xotic750 |
| Keywords | es6, indexOf, extended, module, javascript, nodejs, browser |

## Links

- npm: https://www.npmjs.com/package/index-of-x
- Repository: https://github.com/Xotic750/index-of-x
- Issues: https://github.com/Xotic750/index-of-x/issues
- npm.io page: https://npm.io/package/index-of-x

## Dependencies (13)

- [is-nan-x](https://npm.io/package/is-nan-x.md) ^2.1.1
- [attempt-x](https://npm.io/package/attempt-x.md) ^2.1.2
- [is-string](https://npm.io/package/is-string.md) ^1.0.4
- [to-length-x](https://npm.io/package/to-length-x.md) ^4.2.2
- [to-object-x](https://npm.io/package/to-object-x.md) ^2.2.1
- [find-index-x](https://npm.io/package/find-index-x.md) ^3.1.2
- [same-value-x](https://npm.io/package/same-value-x.md) ^2.1.1
- [to-boolean-x](https://npm.io/package/to-boolean-x.md) ^2.1.1
- [to-integer-x](https://npm.io/package/to-integer-x.md) ^4.2.2
- [same-value-zero-x](https://npm.io/package/same-value-zero-x.md) ^2.1.1
- [simple-methodize-x](https://npm.io/package/simple-methodize-x.md) ^1.0.4
- [split-if-boxed-bug-x](https://npm.io/package/split-if-boxed-bug-x.md) ^2.1.2
- [calculate-from-index-x](https://npm.io/package/calculate-from-index-x.md) ^3.1.2

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 3.1.2 (latest) — 2019-08-28
- 3.1.1 — 2019-08-20
- 3.1.0 — 2019-08-14
- 3.0.18 — 2019-08-05
- 3.0.17 — 2019-07-31
- 3.0.16 — 2019-07-27
- 3.0.15 — 2019-07-27
- 3.0.14 — 2019-07-26
- 3.0.13 — 2019-07-25
- 3.0.12 — 2019-07-24
- 3.0.11 — 2019-07-24
- 3.0.10 — 2019-07-22
- 3.0.9 — 2019-07-21
- 3.0.8 — 2019-07-19
- 3.0.7 — 2019-07-18
- … 42 more at https://npm.io/package/index-of-x/versions

## README

<a
  href="https://travis-ci.org/Xotic750/index-of-x"
  title="Travis status">
<img
  src="https://travis-ci.org/Xotic750/index-of-x.svg?branch=master"
  alt="Travis status" height="18">
</a>
<a
  href="https://david-dm.org/Xotic750/index-of-x"
  title="Dependency status">
<img src="https://david-dm.org/Xotic750/index-of-x/status.svg"
  alt="Dependency status" height="18"/>
</a>
<a
  href="https://david-dm.org/Xotic750/index-of-x?type=dev"
  title="devDependency status">
<img src="https://david-dm.org/Xotic750/index-of-x/dev-status.svg"
  alt="devDependency status" height="18"/>
</a>
<a
  href="https://badge.fury.io/js/index-of-x"
  title="npm version">
<img src="https://badge.fury.io/js/index-of-x.svg"
  alt="npm version" height="18">
</a>
<a
  href="https://www.jsdelivr.com/package/npm/index-of-x"
  title="jsDelivr hits">
<img src="https://data.jsdelivr.com/v1/package/npm/index-of-x/badge?style=rounded"
  alt="jsDelivr hits" height="18">
</a>
<a
  href="https://bettercodehub.com/results/Xotic750/index-of-x"
  title="bettercodehub score">
<img src="https://bettercodehub.com/edge/badge/Xotic750/index-of-x?branch=master"
  alt="bettercodehub score" height="18">
</a>
<a
  href="https://coveralls.io/github/Xotic750/index-of-x?branch=master"
  title="Coverage Status">
<img src="https://coveralls.io/repos/github/Xotic750/index-of-x/badge.svg?branch=master"
  alt="Coverage Status" height="18">
</a>

<a name="module_index-of-x"></a>

## index-of-x

An extended ES6 indexOf.

**Version**: 2.3.0  
**Author**: Xotic750 <Xotic750@gmail.com>  
**License**: [MIT](https://opensource.org/licenses/MIT)  
**Copyright**: Xotic750  
<a name="exp_module_index-of-x--module.exports"></a>

### `module.exports(array, searchElement, [fromIndex], [extend])` ⇒ <code>number</code> ⏏

This method returns the first index at which a given element can be found
in the array, or -1 if it is not present.

**Kind**: Exported function  
**Returns**: <code>number</code> - Returns index of found element, otherwise -1.  
**Throws**:

- <code>TypeError</code> If `array` is `null` or `undefined`.

| Param         | Type                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| array         | <code>Array</code>  | The array to search.                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| searchElement | <code>\*</code>     | Element to locate in the `array`.                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| [fromIndex]   | <code>number</code> | The index to start the search at. If the index is greater than or equal to the array's length, -1 is returned, which means the array will not be searched. If the provided index value is a negative number, it is taken as the offset from the end of the array. Note: if the provided index is negative, the array is still searched from front to back. If the calculated index is less than 0, then the whole array will be searched. Default: 0 (entire array is searched). |
| [extend]      | <code>string</code> | Extension type: `SameValue` or `SameValueZero`.                                                                                                                                                                                                                                                                                                                                                                                                                                  |

**Example**

```js
import indexOf from 'index-of-x';

const subject = [2, 3, undefined, true, 'hej', null, 2, false, 0, -0, NaN];

// Standard mode, operates just like `Array.prototype.indexOf`.
console.log(indexOf(subject, null)); // 5
console.log(indexOf(subject, '2')); // -1
console.log(indexOf(subject, NaN)); // -1
console.log(indexOf(subject, -0)); // 8
console.log(indexOf(subject, 2, 2)); //6

// `SameValueZero` mode extends `indexOf` to match `NaN`.
console.log(indexOf(subject, null, 'SameValueZero')); // 5
console.log(indexOf(subject, '2', 'SameValueZero')); // -1
console.log(indexOf(subject, NaN, 'SameValueZero')); // 10
console.log(indexOf(subject, -0, 'SameValueZero')); // 8
console.log(indexOf(subject, 2, 2, 'SameValueZero')); //6

// `SameValue` mode extends `indexOf` to match `NaN` and signed `0`.
console.log(indexOf(subject, null, 'SameValue')); // 5
console.log(indexOf(subject, '2', 'SameValue')); // -1
console.log(indexOf(subject, NaN, 'SameValue')); // 10
console.log(indexOf(subject, -0, 'SameValue')); // 9
console.log(indexOf(subject, 2, 2, 'SameValue')); //6
```

---
_Source: https://npm.io/package/index-of-x · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
