Created
April 8, 2015 19:45
-
-
Save malectro/455607d0022e57faca09 to your computer and use it in GitHub Desktop.
Executes an array of promises in sequence. Useful when all promises access the same lock and could possibly time out if run in parallel (as in a database migration).
This file contains hidden or 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 forEachPromise = function (array, callback) { | |
var i = 0; | |
function iterate() { | |
if (i < array.length) { | |
callback(arrray[i]).then(function () { | |
i++; | |
iterate(); | |
}); | |
} | |
} | |
iterate(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment