@writetome51/array-get-indexes-that-pass
v1.0.0
Published
Returns indexes of array items that pass a test
Downloads
2
Maintainers
Readme
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'