Skip to content

Instantly share code, notes, and snippets.

@Will-Sommers
Created July 22, 2014 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Will-Sommers/046d16d52664824108a7 to your computer and use it in GitHub Desktop.
Save Will-Sommers/046d16d52664824108a7 to your computer and use it in GitHub Desktop.
for Manish
function hiManish(fn, calls) {
var calls_count = calls;
return {
completeCall: function() {
calls -= 1;
if (this.isDone()){
console.log("Begin to execute callback function")
fn.call(this)
}
},
isDone: function() {
return calls === 0;
}
}}
var hi_lo = hiManish(function() { [1,2,3,4,5]}forEach(function (n) { console.log(n)})}, 3);
hi_lo.completeCall();
hi_lo.completeCall();
hi_lo.completeCall();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment