Filter object keys and values into a new object
$ npm install --save filter-obj
const filterObj = require('filter-obj');
const obj = {
foo: true,
bar: false
};
const newObject = filterObj(obj, (key, value) => value === true);
//=> {foo: true}
const newObject2 = filterObj(obj, ['bar']);
//=> {bar: true}
Type: object
Source object to filter properties from.
Type: array
function
Array of properties that should be filtered from the object or a filter function. The function has the signature filterFn(sourceKey, sourceValue, source)
.
- map-obj - Map object keys and values into a new object
- object-assign - Copy enumerable own properties from one or more source objects to a target object
MIT © Sindre Sorhus