JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 11019301
  • Score
    100M100P100Q222518F
  • License MIT

Filter object keys and values into a new object

Package Exports

  • filter-obj

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (filter-obj) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

filter-obj Build Status

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: Function

A predicate function that detemines whether a property should be assigned to the new object. The function has the signature filterFunction(sourceKey, sourceValue, source).

includeKeys

Type: string[]

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

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