-
Notifications
You must be signed in to change notification settings - Fork 1
searchAll
Subhajit Sahu edited this page Jun 15, 2020
·
29 revisions
Searches values passing a test. 🏃 📼 📦 🌔 📒
Alternatives: search, searchRight, searchAll.
Similar: search, scan, find.
iterable.searchAll(x, fn);
// x: an iterable
// fn: test function (v, i, x)
// --> indices of value
const iterable = require('extra-iterable');
var x = [1, 2, 3, 4, 5];
[...iterable.searchAll(x, v => v % 2 == 0)];
// [ 1, 3 ] ^ ^
[...iterable.searchAll(x, v => v % 2 == 1)];
// [ 0, 2, 4 ] ^ ^