Skip to content
Subhajit Sahu edited this page Jun 18, 2020 · 14 revisions

Finds key of an entry passing a test. 🏃 📼 📦 🌔 📒

Alternatives: search, searchAll.
Similar: find, search, searchValue.

lists.search(x, ft);
// x:  lists
// ft: test function (v, k, x)
const entries = require('extra-entries');

var x = [['a', 1], ['b', 2], ['c', 3], ['d', 2]];
entries.search(x, v => v === 2);
// 'b'                       ^

entries.search(x, v => v === 4);
// undefined

references

Clone this wiki locally