@ndhoule/includes
Version:
Determine whether or not a value is contained by a given collection.
46 lines (29 loc) • 915 B
Markdown
Determine whether or not a value is contained by a given collection.
Uses [SameValueZero][] (the algorithm used by Object.is) for equality comparisons.
```sh
$ component install ndhoule/includes
$ npm install @ndhoule/includes
```
```javascript
includes(2, [1, 2, 3]);
//=> true
includes(4, [1, 2, 3]);
//=> false
includes(2, { a: 1, b: 2, c: 3 });
//=> true
includes('a', { a: 1, b: 2, c: 3 });
//=> false
includes('abc', 'xyzabc opq');
//=> true
includes('nope', 'xyzabc opq');
//=> false
```
Released under the [MIT license](LICENSE.md).
[]: https://esdiscuss.org/topic/samevaluezero-comparator-and-compatibility
[]: https://travis-ci.org/ndhoule/includes
[]: https://travis-ci.org/ndhoule/includes.svg?branch=master