Created
February 25, 2013 19:04
-
-
Save warseph/5032322 to your computer and use it in GitHub Desktop.
Simple function locking in javascript
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
| var lock; | |
| lock = function (object, functionName, lockFunction) { | |
| 'use strict'; | |
| var old; | |
| if (object[functionName].locked) { | |
| return false; | |
| } | |
| old = object[functionName]; | |
| object[functionName] = lockFunction; | |
| object[functionName].locked = true; | |
| return function () { | |
| object[functionName] = old; | |
| }; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use it?