npm.io
1.1.7 • Published 7 years ago

@extra-array/indices-of

Licence
MIT
Version
1.1.7
Deps
0
Size
3 kB
Vulns
0
Weekly
0
Stars
17

Get indices of all values in array equal to specified value, like Array.indexOf().

const indicesOf = require('@extra-array/indices-of');
// indicesOf(<array>, <search value>, [begin=0], [end], [target=[]], [at])

indicesOf(['r', 'o', 'b', 'o'], 'o');
// [1, 3]
indicesOf(['r', 'o', 'b', 'o'], 'o', 1);
// [1, 3]
indicesOf(['r', 'o', 'b', 'o'], 'o', 1, 3);
// [1]
indicesOf(['r', 'o', 'b', 'o'], 'o', 1, 3, [10, 11]);
// [10, 11, 1]
indicesOf(['r', 'o', 'b', 'o'], 'o', 1, 3, [10, 11], 1);
// [10, 1]

With extra-array try Array.indicesOf() instead.


extra-array

Keywords