1.0.0 • Published 4 years ago

@writetome51/array-get-indexes-that-pass v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

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'