Last active
November 21, 2018 04:34
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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