Skip to content

searchAll

Subhajit Sahu edited this page May 10, 2020 · 29 revisions

Searches a value throughout. 🏃 📼 📦 🌔

Alternatives: left, right, all.

iterable.searchAll(x, v, [fn]);
// x:  an iterable
// v:  search value
// fn: compare function (a, b)
// --> 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]   ^      ^

references

Clone this wiki locally