README
Filter
Filter an object, array or string and keep the result as the same type.
Installation
npm install util-filter --save
Usage
var filter = require('util-filter');
// Filter over objects.
filter({
a: 0,
b: 1,
c: 2
}, function (value, key, obj) {
return value < 2;
});
//=> { a: 0, b: 1 }
// Filter over arrays.
filter(['a', 'b', 'c'], function (value, key, obj) {
return key % 2;
});
// => ['b']
// Filter over strings.
filter('abc', function (value, key, obj) {
return true;
});
//=> 'abc'
License
MIT