@f/filter

1.1.1 • Public • Published

filter

Build status Git tag NPM version Code style

Filter for various data types.

Installation

$ npm install @f/filter

Usage

var filter = require('@f/filter')

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

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

API

filter(fn, val)

  • fn - Predicate function. Called like fn(val, key) returns a boolean indicating whether to keep that key/value pair.
  • val - A container of some kind (object or array at the moment)

Returns: A new container of the same type as val containing only the key/value pairs that fn(val, key) returned truthy for.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @f/filter

Weekly Downloads

0

Version

1.1.1

License

MIT

Last publish

Collaborators

  • f