JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 282
  • Score
    100M100P100Q90370F
  • License MIT

Return positive value if any of passed values exists in array.

Package Exports

  • arr-includes

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (arr-includes) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

arr-includes npmjs.com The MIT License npm downloads

Return positive value if any of passed values exists in array.

code climate standard code style travis build status coverage status dependency status

Install

npm i arr-includes --save

Usage

For more use-cases see the tests

const arrIncludes = require('arr-includes')

arrIncludes

Check any of values exists on arr.

Example

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

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

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github