find-indexes
v1.0.1
Published
Like Array#findIndex() but return all indexes
Downloads
5
Maintainers
Readme
find-indexes
Like Array#findIndex()
, but return all indexes instead of the first one
import findIndexes from 'find-indexes';
findIndexes(['a', 'b', 'c', 'b'], val => val === 'b'); //=> [1, 3]
Installation
npm
npm install find-indexes
bower
bower install find-indexes
API
import findIndexes from 'find-indexes';
findIndexes(array, fn)
array: Array
fn: Function
Return: Array
It returns all indexes of the the array that satisfy the provided testing function. Otherwise it returns an empty array.
findIndexes([0.1, 0.5], Math.ceil); //=> [0, 1]
findIndexes([0.1, 0.5], Math.round); //=> [1]
findIndexes([0.1, 0.5], Math.floor); //=> []
Related projects
- arr-indexes-of -
Array#indexOf()
version - str-indexes-of -
String#indexOf()
version