Skip to content

Instantly share code, notes, and snippets.

@ayal
Created May 14, 2011 11:46
Show Gist options
  • Save ayal/972143 to your computer and use it in GitHub Desktop.
Save ayal/972143 to your computer and use it in GitHub Desktop.
var i = 0;
var len = object.length;
objects.forEach(function() {
if (something) {
doSomethingAsync(function(data) {
doSomethingWithData(data);
if (i === len - 1) {
returnResponseToClient();
}
i++;
});
}
else {
doSomethingElse();
if (i === len - 1) {
returnResponseToClient();
}
i++;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment