Skip to content

Instantly share code, notes, and snippets.

@romeoh
Created March 19, 2013 03:52
Show Gist options
  • Save romeoh/5193607 to your computer and use it in GitHub Desktop.
Save romeoh/5193607 to your computer and use it in GitHub Desktop.
callee
<script defer>
function gate(fn, number_of_calls_before_opening) {
console.log(arguments.callee)
return function() {
arguments.callee._call_count = (arguments.callee._call_count || 0) + 1;
if (arguments.callee._call_count >= number_of_calls_before_opening)
fn.apply(null, arguments);
};
}
var f = gate(function(arg) {
//alert(arg);
}, 1);
f('hello');
f('world');
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment