find - nodef/extra-set GitHub Wiki

Find first value passing a test (default order).

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

function find(x, ft)
// x:  a set
// ft: test function (v, v, x)
const set = require('extra-set');

var x = new Set([1, 2, 3, 4]);
set.find(x, v => v % 2 === 0);
// → 2                             ^

set.find(x, v => v % 8 === 0);
// → undefined

References