Skip to content

Instantly share code, notes, and snippets.

@kurdin
Created April 3, 2020 15:50
Show Gist options
  • Save kurdin/d17916de5d027af6932285818d0f588f to your computer and use it in GitHub Desktop.
Save kurdin/d17916de5d027af6932285818d0f588f to your computer and use it in GitHub Desktop.
tryES6.com/9WS4pMfJT
function runSerial(tasks, fn) {
return tasks.reduce((promise, task) => promise.then(previous => fn(task, previous)), Promise.resolve(null))
}
function runParallel(tasks, fn) {
return Promise.all(tasks.map(task => fn(task)))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment