1.1.1 • Published 5 years ago

@extra-iterable/find-all-indices v1.1.1

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

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

const findAllIndices = require('@extra-iterable/find-all-indices');
// findAllIndices(<iterable>, <test function>, [this], [begin=0], [end], [target=[]], [at])
// - <test function>(<value>, <index>, <iterable>)

findAllIndices(new Set(['a', 'b', 'cd']), (v) => v>'b');
// [2]
findAllIndices('abcd', (v, i, itr) => v>'b', null, 1);
// [2, 3]
findAllIndices('abcd', (v, i, itr) => v>'b', null, 1, 3);
// [2]
findAllIndices('abcd', (v, i, itr) => v>'b', null, 1, 3, [10, 11]);
// [10, 11, 2]
findAllIndices('abcd', (v, i, itr) => v>'b', null, 1, 3, [10, 11], 1);
// [10, 2]

extra-iterable