Skip to content

filter$

Subhajit Sahu edited this page Jun 12, 2020 · 13 revisions

Keeps entries which pass a test. 🏃 [:vhs:] 📦 🌔 📒

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

object.filter$(x, fn, [ths]);
// x:   an object (updated)
// fn:  test function (v, k, x)
// ths: this argument
// --> 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 }
Clone this wiki locally