Skip to content

Implement Promise.series #134

@epoberezkin

Description

@epoberezkin

When you have the list of values to be passed to the same function sequentially, so that the next call is only made only when the promise returned by the previous call is resolved, you either have to "manually" chain promises or use Promise.reduce, which both looks a bit ugly and also not so obvious.

It could be nice to have something like this:

Promise.series = function (arr, iteratorAsync) {
    return Promise.reduce(arr, function(memo, item) {
        return iteratorAsync(item);
    }, 0);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions