@f/reduce-array

Fast and functional array reduce implementation

Stats

StarsIssuesVersionUpdatedCreatedSize
@f/reduce-array
000.2.16 years ago6 years agoMinified + gzip package size for @f/reduce-array in KB

Readme

reduce-array

Build status Git tag NPM version Code style

Fast and functional array reduce implementation. Same concept as the native reduce implementation except different argument order for currying.

Installation

$ npm install @f/reduce-array

Usage

var reduce = require('@f/reduce-array')

var sum = reduce(
  function (prev, curr) {
    return prev + curr
  },
  2,
  [2, 3, 6]
)

// sum -> 13

API

reduceArray(cb, initialValue, arr)

  • cb - Callback called for each arr item with a accumlator value and the current item. Optional index and array
function cb (accumulator, currentItem, index, array) {}
  • initialValue - First value for the accumulator
  • arr Array to be reduced

Returns: The accumulated value

License

MIT

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.