find-indices

0.2.1 • Public • Published

find-indices

Build Status

Returns indexes of elements in an array that satisfy a predicate or a lodash iteratee shorthand.

Like lodash.findindex, but returns all indexes instead of the first one.

Install

npm install find-indices --save

API

find-indices

Parameters

  • array Array The array to search
  • predicate (Function | Array | Object | string) The function invoked per iteration
  • fromIndex number The index to search from (optional, default 0)
  • limit number The maximum number of indexes to search (optional, default -1)

Examples

import findIndexes from 'find-indices';
 
const coll = [{ v: 0 }, { v: 2 }, { v: 0 }, { v: 3 }, { v: 3 }];
findIndexes(coll, ({ v }) => v > 1); // [1, 3, 4]
findIndexes(coll, { v: 0 }); // [0, 2]
findIndexes(coll, ['v', 3]); // [3, 4]
findIndexes(coll, 'v'); // [1, 3, 4]

Returns Array<number> The array of found indexes

Readme

Keywords

none

Package Sidebar

Install

npm i find-indices

Weekly Downloads

15

Version

0.2.1

License

ISC

Unpacked Size

7.73 kB

Total Files

9

Last publish

Collaborators

  • safer-bwd