@f/filter-obj

1.1.1 • Public • Published

filter-obj

Build status Git tag NPM version Code style

Functional, data-last object filter.

Installation

$ npm install @f/filter-obj

Usage

var filterObj = require('@f/filter-obj')

filterObj(isEven, {a: 1, b: 2, c: 3, d: 4, e: 5}) // -> {b: 2, c: 4}

function isEven (n) {
  return n % 2 === 0
}

API

filterObj(fn, obj)

  • fn - The predicate function. Receives fn(val, key) for each key/value pair in the object. Returns a bool indicating whether to keep it or not.
  • obj - The object to filter

Returns: A new object containing only the key/value pairs that passed the fn(val, key) truth test (that it returned truthy for).

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @f/filter-obj

Weekly Downloads

12

Version

1.1.1

License

MIT

Last publish

Collaborators

  • f