array-findallindices

Get indices of all values in array that satisfy the test, like Array.findIndex().

Usage no npm install needed!

<script type="module">
  import arrayFindallindices from 'https://cdn.skypack.dev/array-findallindices';
</script>

README

array-findallindices

NOTE: array-findallindices was renamed to @extra-array/find-all-indices. NPM

Get indices of all values in array that satisfy the test, like Array.findIndex().

const findAllIndices = require('array-findallindices');
// 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]