Skip to content

Instantly share code, notes, and snippets.

@dallonf
Created November 15, 2012 20:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dallonf/307f9378526f46669d8b to your computer and use it in GitHub Desktop.
Save dallonf/307f9378526f46669d8b to your computer and use it in GitHub Desktop.
function doThingsWithItems(callback) {
var items = ["foo", "bar", "baz"];
var remaining = items.length + 1;
items.forEach(function(item) {
doSomethingErrorProne(function() {
remaining -= 1;
if (remaining == 0) {
callback();
}
})
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment