Created
January 25, 2010 20:32
-
-
Save Maciek416/286217 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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