Created
August 10, 2020 06:12
-
-
Save olecksamdr/ab5cfb6cc4a6a42f286aa621732f138e to your computer and use it in GitHub Desktop.
Run the functions in the tasks collection in series, each one running once the previous function has completed
This file contains hidden or 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
/** | |
* series :: array -> Promise | |
* | |
* Run the functions in the tasks collection in series, | |
* each one running once the previous function has completed. | |
*/ | |
const series = tasks => | |
tasks.reduce( | |
(prevPromise, nextPromise) => prevPromise.then(nextPromise), | |
Promise.resolve() | |
); | |
module.exports = { | |
series, | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment