charlike
Version:
Small, fast, simple and streaming project scaffolder for myself, but not only. Supports hundreds of template engines through the @JSTransformers API or if you want custom `render` function passed through options
118 lines (82 loc) • 6.67 kB
Markdown
> Return positive value if any of passed values exists in array.
[![code climate][codeclimate-img]][codeclimate-url] [![standard code style][standard-img]][standard-url] [![travis build status][travis-img]][travis-url] [![coverage status][coveralls-img]][coveralls-url] [![dependency status][david-img]][david-url]
```
npm i arr-includes --save
```
> For more use-cases see the [tests](./test.js)
```js
const arrIncludes = require('arr-includes')
```
> Check any of `values` exists on `arr`.
**Params**
* `arr` **{Array}**: array to check
* `values` **{Array|String}**: array or string
* `returns` **{Boolean|Number}**: returns `false` if not found, `true` if **index is 0** from the array, otherwise `number` index
**Example**
```js
var arrIncludes = require('arr-includes')
console.log(arrIncludes([1, 'bar', 55], 2)) // => false
console.log(arrIncludes([1, 'bar', 3], 3)) // => 2
console.log(arrIncludes([1, 'bar', 3, true], false)) // => false
console.log(arrIncludes([1, 'bar', 44, true], true)) // => 3
console.log(arrIncludes(['foo', 'bar'], 'baz')) // => false
console.log(arrIncludes(['foo', 'bar'], 'foo')) // => true
console.log(arrIncludes(['qux', 'foo', 'bar'], 'foo')) // => 1
console.log(arrIncludes([true, 'qqq', 'bar'], true)) // => true
console.log(arrIncludes(['true', 'qqq', 'bar'], true)) // => false
console.log(arrIncludes(['qqq', 'bar', true], true)) // => 2
console.log(arrIncludes(['qqq', 'true', 'bar'], true)) // => false
console.log(arrIncludes([false, 'foo', null, 'bar'], null)) // => 2
console.log(arrIncludes(['foo', 'bar', 'qux'], ['a', 'b', 'c'])) // => false
console.log(arrIncludes(['b', 'a', 'c'], ['a', 'b', 'c'])) // => 1
console.log(arrIncludes(['foo', 'bb', 'b'], ['a', 'b'])) // => 2
console.log(arrIncludes(['foo', 'bar', 'qux'], ['a', 'b', 'foo'])) // => true
console.log(arrIncludes(['bar', 123, 'foo', 'qux'], ['a', 'b', 'foo'])) // => 2
```
- [in-array](https://www.npmjs.com/package/in-array): Return true if a value exists in an array. Faster than using… [more](https://github.com/jonschlinkert/in-array) | [homepage](https://github.com/jonschlinkert/in-array "Return true if a value exists in an array. Faster than using indexOf and won't blow up on null values.")
- [is-async-function](https://www.npmjs.com/package/is-async-function): Is function really asynchronous function? Trying to guess that based on check… [more](https://github.com/tunnckocore/is-async-function#readme) | [homepage](https://github.com/tunnckocore/is-async-function#readme "Is function really asynchronous function? Trying to guess that based on check if [common-callback-names][] exists as function arguments names or you can pass your custom.")
- [is-installed](https://www.npmjs.com/package/is-installed): Checks that given package is installed on the system - globally or… [more](https://github.com/tunnckoCore/is-installed#readme) | [homepage](https://github.com/tunnckoCore/is-installed#readme "Checks that given package is installed on the system - globally or locally.")
- [is-missing](https://www.npmjs.com/package/is-missing): Check that given `name` or `user/repo` exists in npm registry or in… [more](https://github.com/tunnckocore/is-missing#readme) | [homepage](https://github.com/tunnckocore/is-missing#readme "Check that given `name` or `user/repo` exists in npm registry or in github as user repository.")
- [isarray](https://www.npmjs.com/package/isarray): Array#isArray for older browsers | [homepage](https://github.com/juliangruber/isarray "Array#isArray for older browsers")
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/tunnckoCore/arr-includes/issues/new).
But before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines.
[![tunnckoCore.tk][author-www-img]][author-www-url] [![keybase tunnckoCore][keybase-img]][keybase-url] [![tunnckoCore npm][author-npm-img]][author-npm-url] [![tunnckoCore twitter][author-twitter-img]][author-twitter-url] [![tunnckoCore github][author-github-img]][author-github-url]
[]: https://github.com/jonschlinkert/in-array
[]: https://www.npmjs.com/package/arr-includes
[]: https://img.shields.io/npm/v/arr-includes.svg?label=arr-includes
[]: https://github.com/tunnckoCore/arr-includes/blob/master/LICENSE
[]: https://img.shields.io/npm/l/arr-includes.svg
[]: https://www.npmjs.com/package/arr-includes
[]: https://img.shields.io/npm/dm/arr-includes.svg
[]: https://codeclimate.com/github/tunnckoCore/arr-includes
[]: https://img.shields.io/codeclimate/github/tunnckoCore/arr-includes.svg
[]: https://travis-ci.org/tunnckoCore/arr-includes
[]: https://img.shields.io/travis/tunnckoCore/arr-includes/master.svg
[]: https://coveralls.io/r/tunnckoCore/arr-includes
[]: https://img.shields.io/coveralls/tunnckoCore/arr-includes.svg
[]: https://david-dm.org/tunnckoCore/arr-includes
[]: https://img.shields.io/david/tunnckoCore/arr-includes.svg
[]: https://github.com/feross/standard
[]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
[]: http://www.tunnckocore.tk
[]: https://img.shields.io/badge/www-tunnckocore.tk-fe7d37.svg
[]: https://keybase.io/tunnckocore
[]: https://img.shields.io/badge/keybase-tunnckocore-8a7967.svg
[]: https://www.npmjs.com/~tunnckocore
[]: https://img.shields.io/badge/npm-~tunnckocore-cb3837.svg
[]: https://twitter.com/tunnckoCore
[]: https://img.shields.io/badge/twitter-@tunnckoCore-55acee.svg
[]: https://github.com/tunnckoCore
[]: https://img.shields.io/badge/github-@tunnckoCore-4183c4.svg
[]: http://webchat.freenode.net/?channels=charlike
[]: https://img.shields.io/badge/freenode-%23charlike-5654a4.svg
[]: https://github.com/tunnckoCore/ama
[]: https://img.shields.io/badge/ask%20me-anything-green.svg
[]: https://github.com/tunnckocore/common-callback-names