Skip to content

Instantly share code, notes, and snippets.

@olecksamdr
Created August 10, 2020 06:12
Show Gist options
  • Save olecksamdr/ab5cfb6cc4a6a42f286aa621732f138e to your computer and use it in GitHub Desktop.
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
/**
* 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