@extra-object/filter

Keeps entries which pass a test.

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
@extra-object/filter
032.2.52 years ago3 years agoMinified + gzip package size for @extra-object/filter in KB

Readme

Keeps entries which pass a test. :running: :vhs: :package: :moon: :ledger:
Alternatives: filter, filter$.
Similar: map, reduce, filter, filterAt, reject, rejectAt.
This is part of package extra-object.

object.filter(x, ft);
// x:  an object
// 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 }

object.filter(x, v => v % 2 === 0);
// { b: 2, d: 4 }

references