Skip to content

Instantly share code, notes, and snippets.

@Maciek416
Created January 25, 2010 20:32
Show Gist options
  • Select an option

  • Save Maciek416/286217 to your computer and use it in GitHub Desktop.

Select an option

Save Maciek416/286217 to your computer and use it in GitHub Desktop.
for(var k in p){
if(typeof(p[k])=='function'){
(function(k){
var cachedCommand = commands[k];
commands[k] = function(){
if(ctx == null){
if(strict==true){
throw "No context!";
}
ctx = makeDefaultContext();
} else {
//
// unwrap command k back to fast-executing version
// the first time its called
//
commands[k] = cachedCommand;
}
cachedCommand.apply(p, arguments);
}
})(k);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment