Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ndhoule/includes
Determine whether or not a value is contained by a given collection.
https://github.com/ndhoule/includes
Last synced: 13 days ago
JSON representation
Determine whether or not a value is contained by a given collection.
- Host: GitHub
- URL: https://github.com/ndhoule/includes
- Owner: ndhoule
- License: mit
- Created: 2015-05-19T21:53:46.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-05-02T20:28:14.000Z (over 8 years ago)
- Last Synced: 2024-10-12T21:21:18.353Z (about 1 month ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: HISTORY.md
- License: LICENSE.md
Awesome Lists containing this project
README
# includes [![CI][ci-badge]][ci-link]
Determine whether or not a value is contained by a given collection.
Uses [SameValueZero][] (the algorithm used by Object.is) for equality comparisons.
## Installation
```sh
$ component install ndhoule/includes
$ npm install @ndhoule/includes
```## API
### `includes(searchElement : *, collection : Object|Array|string) => boolean`
```javascript
includes(2, [1, 2, 3]);
//=> trueincludes(4, [1, 2, 3]);
//=> falseincludes(2, { a: 1, b: 2, c: 3 });
//=> trueincludes('a', { a: 1, b: 2, c: 3 });
//=> falseincludes('abc', 'xyzabc opq');
//=> trueincludes('nope', 'xyzabc opq');
//=> false
```## License
Released under the [MIT license](LICENSE.md).
[SameValueZero]: https://esdiscuss.org/topic/samevaluezero-comparator-and-compatibility
[ci-link]: https://travis-ci.org/ndhoule/includes
[ci-badge]: https://travis-ci.org/ndhoule/includes.svg?branch=master