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

Keeps entries which pass a test. 🏃 📼 📦 🌔 📒

Similar: map, reduce, filter, filterAt, reject, rejectAt.

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

var x = [['a', 1], ['b', 2], ['c', 3], ['d', 4], ['e', 5]];
[...entries.filter(x, v => v % 2 === 1)];
// [ [ 'a', 1 ], [ 'c', 3 ], [ 'e', 5 ] ]

[...entries.filter(x, v => v % 2 === 0)];
// [ [ 'b', 2 ], [ 'd', 4 ] ]

references

Clone this wiki locally