Skip to content

Repository files navigation

filter-obj Build Status

Filter object keys and values into a new object

Install

$ npm install --save filter-obj

Usage

constfilterObj=require('filter-obj');constobj={foo: true,bar: false};constnewObject=filterObj(obj,(key,value)=>value===true);//=> {foo: true}constnewObject2=filterObj(obj,['bar']);//=> {bar: true}

API

filterObj(source, filter)

source

Type: object

Source object to filter properties from.

filter

Type: arrayfunction

Array of properties that should be filtered from the object or a filter function. The function has the signature filterFn(sourceKey, sourceValue, source).

Related

  • 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

License

MIT © Sindre Sorhus

About

Filter object keys and values into a new object

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages