Mohammad Asif cf937194cb Removed un-waned things 1. 5 months ago
..
index.d.ts cf937194cb Removed un-waned things 1. 5 months ago
index.js cf937194cb Removed un-waned things 1. 5 months ago
license cf937194cb Removed un-waned things 1. 5 months ago
package.json cf937194cb Removed un-waned things 1. 5 months ago
readme.md cf937194cb Removed un-waned things 1. 5 months ago

readme.md

filter-obj

Filter object keys and values into a new object

Install

$ npm install filter-obj

Usage

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}

API

filterObject(source, filter)

filterObject(source, includeKeys)

source

Type: object

Source object to filter properties from.

filter

Type: (sourceKey, sourceValue, source) => boolean

A predicate function that detemines whether a property should be assigned to the new object.

includeKeys

Type: string[]

Array of property names that should be assigned to the new object.

Related

  • map-obj - Map object keys and values into a new object