-
Notifications
You must be signed in to change notification settings - Fork 0
searchValue
Subhajit Sahu edited this page Feb 4, 2021
·
14 revisions
Finds key with given value. 📦 😺 🏃 📼 🌔 📜 📰 📘
Alternatives: searchValue, searchValueAll.
Similar: search, searchValue.
lists.searchValue(x, v, [fc], [fm]);
// x: lists
// v: search value
// fc: compare function (a, b)
// fm: map function (v, k, x)
const lists = require('extra-lists');
var x = [['a', 'b', 'c', 'd', 'e'], [1, -2, 3, 2, 5]];
lists.searchValue(x, 2);
// 'd' ^
lists.searchValue(x, 2, (a, b) => Math.abs(a) - Math.abs(b));
// 'b' ^
lists.searchValue(x, 2, null, v => Math.abs(v));
// 'b' ^