Created
July 22, 2014 21:46
-
-
Save Will-Sommers/046d16d52664824108a7 to your computer and use it in GitHub Desktop.
for Manish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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