Skip to content
Subhajit Sahu edited this page May 7, 2020 · 15 revisions

Get first value in lists that satisfies the test, like Array.find().

const find = require('@extra-lists/find');
// find(<lists>, <test function>, [this])

a = ['edge', 'opera', 'chrome'];
find([a.keys(), a], (v) => v.includes('r'));
// 'opera'
a = {s1: 'bing', s2: 'duckduckgo', s3: 'google'};
find([Object.keys(a), Object.values(a)], (v, i, lst) => v.length>4);
// 'duckduckgo'

extra-lists

Clone this wiki locally