Skip to content

Instantly share code, notes, and snippets.

@jpablo
Created July 16, 2012 02:20
Show Gist options
  • Save jpablo/3120003 to your computer and use it in GitHub Desktop.
Save jpablo/3120003 to your computer and use it in GitHub Desktop.
async map
function asyncMap(promises, callback) {
var results = [];
for(var p in promises) {
if(!promises.hasOwnProperty(p)) { continue; }
promises[p].done(function(result) {
results.push(callback(result))
})
}
return $.when.apply(null,promises).pipe(function() { return results });
}​
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment