$ cnpm install filter-obj
Filter object keys and values into a new object
$ npm install filter-obj
import filterObject from 'filter-obj';
const object = {
foo: true,
bar: false
};
const newObject = filterObject(object, (key, value) => value === true);
//=> {foo: true}
const newObject2 = filterObject(object, ['bar']);
//=> {bar: false}
Type: object
The source object to filter properties from.
Type: (sourceKey, sourceValue, source) => boolean
A predicate function that detemines whether a property should be assigned to the new object.
Type: string[]
An array of property names that should be assigned to the new object.
Copyright 2013 - present © cnpmjs.org