@extra-array/find-all-indices

1.1.7 • Public • Published

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.


extra-array

Package Sidebar

Install

npm i @extra-array/find-all-indices

Weekly Downloads

2

Version

1.1.7

License

MIT

Unpacked Size

3.14 kB

Total Files

4

Last publish

Collaborators

  • wolfram77