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-async
Syntax
reduceRightAsync(array, iteratee, done[, initialValue])
Parameters
-
array
Array - The array to reduce. -
iteratee
Function - The function to execute on each value in the array, taking five arguments:-
prev
Any - The value previously returned in the last invocation of the iteratee, orinitialValue
if supplied. -
curr
Any - The current element being processed in the array. -
n
Integer - The index of the current element being processed in the array. -
arr
Array - The arrayreduceRightAsync
was called upon. -
next
Function - The function to call when you are ready to advance to the next element in the array.
-
-
done
Function - The function called when the reduce has finished, taking one argument:result
Any - The value that results from the reduction.
-
initialValue
Any (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.
); -
Asynchronously flatten an array of arrays,
); -
Asynchronously concatenate all words within an array together starting from an initial value of
"baz"
.);