Skip to content

searchValueAll

Subhajit Sahu edited this page Jun 17, 2020 · 13 revisions

Finds keys with given value. 🏃 📼 📦 🌔 📒

Alternatives: searchValue, searchValueAll.
Similar: search, searchValue.

entries.searchValueAll(x, v, [fc], [fm]);
// x:  entries
// v:  search value
// fc: compare function (a, b)
// fm: map function (v, k, x)
const entries = require('extra-entries');

var x = new Map([['a', 1], ['b', -2], ['c', 3], ['d', 2], ['e', 5]]);
map.searchValueAll(x, 2);
// [ 'd' ]                                        ^

map.searchValueAll(x, 2, (a, b) => Math.abs(a) - Math.abs(b));
// [ 'b', 'd' ]               ^                   ^

map.searchValueAll(x, 2, null, v => Math.abs(v));
// [ 'b', 'd' ]               ^                   ^

references

Clone this wiki locally