scriptex/async-array-prototype

Async reduce

scriptex opened this issue · 1 comments

Here is an example implementation:

import { throws } from '../utils';

export const reduceAsync = async function(fn, accumulator, thisArg) {
    throws(this, fn);

    let result = accumulator;

    for (value of this) {
        result = await fn.call(thisArg, accumulator, value);
    }

    return result;
}

Added in d4bf9ad