1.0.1 • Published 7 years ago

find-indexes v1.0.1

Weekly downloads
3
License
CC0-1.0
Repository
github
Last release
7 years ago

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

Related projects

License

Creative Commons Zero v1.0 Universal