@extra-array/find-all-indices
v1.1.7
Published
Get indices of all values in array that satisfy the test, like Array.findIndex().
Downloads
78
Maintainers
Readme
Get indices of all values in array that satisfy the test, like Array.findIndex().
const findAllIndices = require('@extra-array/find-all-indices');
// findAllIndices(<array>, <test function>, [this], [begin=0], [end], [target=[]], [at])
// - <test function>(<value>, <index>, <array>)
findAllIndices(['a', 'b', 'cd'], (v) => v>'b');
// [2]
findAllIndices(['a', 'b', 'c', 'd'], (v, i, arr) => v>'b', null, 1);
// [2, 3]
findAllIndices(['a', 'b', 'c', 'd'], (v, i, arr) => v>'b', null, 1, 3);
// [2]
findAllIndices(['a', 'b', 'c', 'd'], (v, i, arr) => v>'b', null, 1, 3, [10, 11]);
// [10, 11, 2]
findAllIndices(['a', 'b', 'c', 'd'], (v, i, arr) => v>'b', null, 1, 3, [10, 11], 1);
// [10, 2]
With extra-array try
Array.findAllIndices()
instead.