1.1.1 • Published 8 years ago

@f/filter-array v1.1.1

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

filter-array

Build status Git tag NPM version Code style

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

Installation

$ npm install @f/filter-array

Usage

var filterArray = require('@f/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.
  • arr - The array to filter

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

License

MIT