-
Notifications
You must be signed in to change notification settings - Fork 3
filter$
Subhajit Sahu edited this page Dec 8, 2022
·
13 revisions
Keep entries which pass a test.
Alternatives: filter, filter$.
Similar: filter, filterAt.
Similar: map, reduce, filter, reject.
function filter$(x, ft)
// x: an object (updated)
// ft: test function (v, k, x)
const object = require('extra-object');
var x = {a: 1, b: 2, c: 3, d: 4, e: 5};
object.filter$(x, v => v % 2 === 1);
// → { a: 1, c: 3, e: 5 }
x;
// → { a: 1, c: 3, e: 5 }
var x = {a: 1, b: 2, c: 3, d: 4, e: 5};
object.filter$(x, v => v % 2 === 0);
// → { b: 2, d: 4 }