Skip to content

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.findIndices(x, v => v % 2 == 0)];
// [ 1, 3 ] ^     ^

[...iterable.findIndices(x, v => v % 2 == 1)];
// [ 0, 2, 4 ] ^     ^

references

Clone this wiki locally