find-indexes

1.0.1 • Public • Published

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

Package Sidebar

Install

npm i find-indexes

Weekly Downloads

1

Version

1.0.1

License

CC0-1.0

Last publish

Collaborators

  • shinnn