Reduce an array of values via an asynchronous function.
var fs = ;var path = ;var asyncReduce = ; ;
sizes:
{ '.gitignore': 97,
'.jshintrc': 249,
'.travis.yml': 48,
'index.js': 1534,
'Readme.md': 2160 }
Features
- super small library built on top of also quite small runnel
- since runnel
try/catch
es and bubbles errors and reports with detailed stack traces, so does asyncreduce
Installation
npm install asyncreduce
In the browser
browserify
WithYou are all good.
Without browserify
Two options:
- run browserify --standalone after installing this package via npm
- download the asyncreduce standalone version, powered by browserify as a service
API
function asyncReduce (items, seed, iterator, done)
/**
* Calls provided async iterator function with the accumulator and each item.
* When all items have been iterated over calls done with a possible error or the final value of the accumulator.
*
* @name exports
* @function
* @param items {Array} the items to be reduced
* @param seed {T} the initial value that can be of any type and is passed along as the accumulator (acc) each time the iterator is called
* @param iterator {Function} function (acc, item, callback) {} - the iterator called for each item
* @param done {Function} function (err, acc) {} - called with final accumulated value or an error if one occurred
*/
License
MIT