Skip to content

Instantly share code, notes, and snippets.

@matthewmueller
Created March 11, 2012 23:18
Show Gist options
  • Select an option

  • Save matthewmueller/2018609 to your computer and use it in GitHub Desktop.

Select an option

Save matthewmueller/2018609 to your computer and use it in GitHub Desktop.
Javascript: after(len) - counter used for async iteration
/*
Counter used for async calls
Example:
var files = ['a', 'b'];
finished = after(files.length);
finished() // false
finished() // true
*/
var after = exports.after = function(length) {
var left = length;
return function() {
return (--left <= 0);
};
};
@rviscomi

Copy link
Copy Markdown

Consider this?

return (--left <= 0);

@matthewmueller

Copy link
Copy Markdown
Author

Ohh concise. I like it - I'll update now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment