Skip to content

Instantly share code, notes, and snippets.

@MaximeHeckel
Last active November 21, 2018 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaximeHeckel/d709d2e16f9af800ae848f7d7d8c5ac3 to your computer and use it in GitHub Desktop.
Save MaximeHeckel/d709d2e16f9af800ae848f7d7d8c5ac3 to your computer and use it in GitHub Desktop.
A quick implementation to allow running a given set of promises in sequence
const sequence = ['arg1', 'arg2','arg3'].reduce(async (previousPromise, nextArg) => {
await previousPromise;
return somePromise(nextArg)
}, Promise.resolve());
sequence
.then(() => console.log('Done'))
.catch((e) => console.error(`An error occured: ${e}`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment