accumulate-values
Accumulate values via a reducer
Install
$ npm install --save accumulate-values
Usage
var accumulate = ;0 1 2 // => 3;'0' '1' '2' // => '012';0 1 2 3 // => 6
API
accumulate()
-> function
Returns a function to be passed to Array.prototype.reduce. If the first item in the array is a number, future values are added to the initial value. If it is a string, future values are concatenated. If it is an array, future values are concatenated via [].concat
.
License
MIT © Ben Drucker