Created
February 7, 2013 19:33
-
-
Save medikoo/4733509 to your computer and use it in GitHub Desktop.
Process promises sequentially
This file contains 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
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