-
Notifications
You must be signed in to change notification settings - Fork 0
searchValueAll
Subhajit Sahu edited this page Feb 4, 2021
·
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 = [["a", 1], ["b", -2], ["c", 3], ["d", 2], ["e", 5]];
[...entries.searchValueAll(x, 2)];
// [ "d" ] ^
[...entries.searchValueAll(x, 2, (a, b) => Math.abs(a) - Math.abs(b))];
// [ "b", "d" ] ^ ^
[...entries.searchValueAll(x, 2, null, v => Math.abs(v))];
// [ "b", "d" ] ^ ^