Skip to content

searchValue

Subhajit Sahu edited this page Feb 3, 2021 · 12 revisions

Finds key with given value. 📦 😺 🏃 📼 🌔 📜 📰 📘

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


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

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

map.searchValue(x, 2, (a, b) => Math.abs(a) - Math.abs(b));
// "b"                       ^

map.searchValue(x, 2, null, v => Math.abs(v));
// "b"                       ^


References

Clone this wiki locally