Reduce an array, or a promise of an array, which contains a promises (or a
mix of promises and values) with the given reducer function with the
signature (total, current, index) where current is the resolved value of
a respective promise in the input array. If any promise in the input array is
rejected the returned promise is rejected as well.
If the reducer function returns a promise or a thenable, the result for the
promise is awaited for before continuing with next iteration.
The original array is not modified. If no initialValue is given and the
array doesn't contain at least 2 items, the callback will not be called and
undefined is returned. If no initialValue is given and the array contains
at least two items, the first element is used as the initial value. If
initialValue is given and the array doesn't have at least 1 item,
initialValue is returned.
Reduce an array, or a promise of an array, which contains a promises (or a mix of promises and values) with the given reducer function with the signature
(total, current, index)wherecurrentis the resolved value of a respective promise in the input array. If any promise in the input array is rejected the returned promise is rejected as well.If the reducer function returns a promise or a thenable, the result for the promise is awaited for before continuing with next iteration.
The original array is not modified. If no
initialValueis given and the array doesn't contain at least 2 items, the callback will not be called andundefinedis returned. If noinitialValueis given and the array contains at least two items, the first element is used as the initial value. IfinitialValueis given and the array doesn't have at least 1 item,initialValueis returned.