npm.io
1.0.1 • Published 9 years ago

find-indexes

Licence
CC0-1.0
Version
1.0.1
Deps
1
Vulns
0
Weekly
0

find-indexes

NPM version Bower version Build Status Coverage Status

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); //=> []

License

Creative Commons Zero v1.0 Universal

Keywords