Skip to content

searchAll

Subhajit Sahu edited this page Dec 28, 2022 · 14 revisions

Find keys of entries passing a test.

Alternatives: search, searchAll.
Similar: search, searchValue.


function searchAll(x, ft)
// x:  ilists
// ft: test function (v, k, x)
const xilists = require('extra-ilists');

var x = [['a', 'b', 'c', 'd'], [1, 2, 3, -2]];
[...xilists.searchAll(x, v => v === 2)];
// → [ 'b' ]           ^

[...xilists.searchAll(x, v => Math.abs(v) === 2)];
// → [ 'b', 'd' ]      ^                   ^


References

Clone this wiki locally