-
Notifications
You must be signed in to change notification settings - Fork 1
searchAll
Subhajit Sahu edited this page May 19, 2020
·
29 revisions
Searches a value throughout. 🏃 📼 📦 🌔 📒
Alternatives: search, searchRight, searchAll.
iterable.searchAll(x, v, [fc], [fm]);
// x: an iterable
// v: search value
// fc: compare function (a, b)
// fm: map function (v, i, x)
// --> indices of value
const iterable = require('extra-iterable');
var x = [1, 2, 3, 2, 5];
[...iterable.searchAll(x, 2)];
// [ 1, 3 ] ^ ^
var x = [1, 2, 3, -2, 5];
[...iterable.searchAll(x, 2, (a, b) => Math.abs(a) - Math.abs(b))];
// [ 1, 3 ] ^ ^
[...iterable.searchAll(x, 2, null, v => Math.abs(v))];
// [ 1, 3 ] ^ ^