Skip to content

Instantly share code, notes, and snippets.

function eachAsync(collection, iterator, callback) {
var iterate = function(i) {
setTimeout(function() {
iterator(collection[i]);
if (i < collection.length-1) {
iterate(i + 1);
} else {
if(callback) callback();
}
}, 0);