Skip to content

Instantly share code, notes, and snippets.

@briancavalier
Created March 25, 2013 17:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briancavalier/5238972 to your computer and use it in GitHub Desktop.
Save briancavalier/5238972 to your computer and use it in GitHub Desktop.
Wait for all promises to settle
function settleAll(array) {
return when(array, function(array) {
var i, len, results;
results = [];
for(i = 0, len = array.length; i < len; i++) {
if(i in array) {
results[i] = when(array[i], null, identity);
}
}
return results;
}, function() {
return array;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment