Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

This comment has been minimized.

Copy link

commented Mar 11, 2012

Consider this?

return (--left <= 0);
@matthewmueller

This comment has been minimized.

Copy link
Owner Author

commented Mar 12, 2012

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
You can’t perform that action at this time.