Mohammad Asif cf937194cb Removed un-waned things 1. | 5 mēneši atpakaļ | |
---|---|---|
.. | ||
index.d.ts | 5 mēneši atpakaļ | |
index.js | 5 mēneši atpakaļ | |
license | 5 mēneši atpakaļ | |
package.json | 5 mēneši atpakaļ | |
readme.md | 5 mēneši atpakaļ |
Filter object keys and values into a new object
$ npm install filter-obj
const filterObject = require('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
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[]
Array of property names that should be assigned to the new object.