Skip to content

micro-js/reduce-array

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Fast and functional reduce implementation

Resources

Stars

Watchers

Forks

Packages

No packages published