@micro-js/filter-array

1.0.0 • Public • Published

filter-array

Build status Git tag NPM version Code style

Functional, data-first array filter. Should also be faster than the native Array.prototype.filter

Installation

$ npm install @micro-js/filter-array

Usage

var filterArray = require('@micro-js/filter-array')

filterArray(isEven, [1,2,3,4,5]) // -> [2, 4]

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

API

filterArray(fn, arr)

  • fn - The predicate function that decides whether the value is kept. Receives (value, index) for each value in the array.

Returns: A new array containing only the values for which fn(value, index) returned truthy.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i @micro-js/filter-array

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • micro-js