-
Notifications
You must be signed in to change notification settings - Fork 1
search
Subhajit Sahu edited this page Dec 5, 2022
·
17 revisions
Find key of an entry passing a test.
Alternatives: search, searchAll.
Similar: find, search, searchValue.
function search(x, ft)
// x: a map
// ft: test function (v, k, x)
const map = require('extra-map');
var x = new Map([['a', 1], ['b', 2], ['c', 3], ['d', 2]]);
map.search(x, v => v === 2);
// → 'b' ^
map.search(x, v => v === 4);
// → undefined