Skip to content

Instantly share code, notes, and snippets.

@bradparks
Forked from dtao/eachAsync.js
Created July 3, 2013 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bradparks/5918739 to your computer and use it in GitHub Desktop.
Save bradparks/5918739 to your computer and use it in GitHub Desktop.
function eachAsync(collection, iterator, callback) {
var iterate = function(i) {
setTimeout(function() {
iterator(collection[i]);
if (i < collection.length) {
iterate(i + 1);
} else {
callback();
}
}, 0);
};
iterate(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment