0.1.8 • Published 6 years ago
iterable-findall v0.1.8
iterable-findall
NOTE: iterable-findall was renamed to @extra-iterable/find-all.
Get all values in iterable that satisfy the test, like Array.find().
const findAll = require('iterable-findall');
// findAll(<iterable>, <test function>, [this], [begin=0], [end], [target=[]], [at])
// - <test function>(<value>, <index>, <iterable>)
findAll(new Set(['a', 'b', 'cd']), (v) => v>'b');
// ['cd']
findAll('abcd', (v, i, itr) => v>'b', null, 1);
// ['c', 'd']
findAll('abcd', (v, i, itr) => v>'b', null, 1, 3);
// ['c']
findAll('abcd', (v, i, itr) => v>'b', null, 1, 3, ['z', 'y']);
// ['z', 'y', 'c']
findAll('abcd', (v, i, itr) => v>'b', null, 1, 3, ['z', 'y'], 1);
// ['z', 'c']