reduce-right-async
v0.1.4
Published
Asynchronous Array.reduceRight
Maintainers
Readme
ReduceRightAsync 
Asynchronous Array.reduceRight. The reduceRight() method applies a function against an accumulator and each value of the array (from right-to-left) to reduce it to a single value.
Installation
$ npm install reduce-right-asyncSyntax
reduceRightAsync(array, iteratee, done[, initialValue])Parameters
arrayArray - The array to reduce.iterateeFunction - The function to execute on each value in the array, taking five arguments:prevAny - The value previously returned in the last invocation of the iteratee, orinitialValueif supplied.currAny - The current element being processed in the array.nInteger - The index of the current element being processed in the array.arrArray - The arrayreduceRightAsyncwas called upon.nextFunction - The function to call when you are ready to advance to the next element in the array.
doneFunction - The function called when the reduce has finished, taking one argument:resultAny - The value that results from the reduction.
initialValueAny (Optional) - Value to use as the first argument to the first call of theiteratee.
More information on how reduceRight works.
Examples
Asynchronously sum all the values of an array.
reduceRightAsync([0, 1, 2, 3], (prev, curr, n, arr, next) => { doSomethingAsync(() => { next(prev + curr); }); }, result => { // result == 6 }));Asynchronously flatten an array of arrays,
reduceRightAsync([[0, 1], [2, 3], [4, 5]], (prev, curr, n, arr, next) => { doSomethingAsync(() => { next(prev.concat(curr)); }); }, result => { // result is [4, 5, 2, 3, 0, 1] }));Asynchronously concatenate all words within an array together starting from an initial value of
"baz".reduceRightAsync(['foo', 'bar']], (prev, curr, n, arr, next) => { doSomethingAsync(() => { next(prev + curr); }); }, result => { // result is "bazbarfoo" }, 'baz'));
