filter-obj
Functional, data-last object filter.
Installation
$ npm install @f/filter-obj
Usage
var filterObj = require('@f/filter-obj')
filterObj(isEven, {a: 1, b: 2, c: 3, d: 4, e: 5}) // -> {b: 2, c: 4}
function isEven (n) {
return n % 2 === 0
}
API
filterObj(fn, obj)
-
fn
- The predicate function. Receivesfn(val, key)
for each key/value pair in the object. Returns a bool indicating whether to keep it or not. -
obj
- The object to filter
Returns: A new object containing only the key/value pairs that passed the fn(val, key)
truth test (that it returned truthy for).
License
MIT