Skip to content

Instantly share code, notes, and snippets.

@hacke2
Created September 10, 2015 09:49
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 hacke2/645f7f0061e7bd147bd7 to your computer and use it in GitHub Desktop.
Save hacke2/645f7f0061e7bd147bd7 to your computer and use it in GitHub Desktop.
promise sequence exec tasks
function sequenceTasks(tasks) {
function recordValue(results, value) {
results.push(value);
return results;
}
var pushValue = recordValue.bind(null, []);
return tasks.reduce(function (promise, task) {
return promise.then(task).then(pushValue);
}, Promise.resolve());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment