@writetome51/array-get-indexes-that-pass

1.0.0 • Public • Published

getIndexesThatPass(
     testFunction: (value, index, array) => boolean,
     array
): number[]

Returns indexes of items that pass the testFunction.

Examples

let arr = ['a', 'boy', 'is', 'playing', 'in', 'the', 'street'];

getIndexesThatPass((value) => value.length > 3,  arr);
// --> [3, 6]

getIndexesThatPass((value, i) => (value.length > 3) && (i > 3),  arr);
// --> [6]

Installation

npm i @writetome51/array-get-indexes-that-pass

Loading

import {getIndexesThatPass} from '@writetome51/array-get-indexes-that-pass'

Package Sidebar

Install

npm i @writetome51/array-get-indexes-that-pass

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

2.75 kB

Total Files

4

Last publish

Collaborators

  • writetome51