Skip to content

Instantly share code, notes, and snippets.

@medikoo
Created February 7, 2013 19:33
Show Gist options
  • Save medikoo/4733509 to your computer and use it in GitHub Desktop.
Save medikoo/4733509 to your computer and use it in GitHub Desktop.
Process promises sequentially
var files = [/* list of files */];
var iterate = function () {
var file = files.shift();
return file ? process(file).then(iterate) : null;
};
var process = function (file) {
// ...
return promise;
};
var mainPromise = iterate();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment