@f/reduce-array

0.2.1 • Public • Published

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

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i @f/reduce-array

    Weekly Downloads

    111

    Version

    0.2.1

    License

    MIT

    Last publish

    Collaborators

    • f