Skip to content

Instantly share code, notes, and snippets.

@ccnokes ccnokes/async-series.js
Last active Oct 6, 2016

What would you like to do?
Async series with reduce
function asyncThing() {
return new Promise(res => {
setTimeout(() => {
}, 1000);
function series(...promises) {
return promises.reduce((p, fn) => p.then(fn), Promise.resolve());
series(asyncThing, asyncThing, asyncThing)
.then(result => console.log(result));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.