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 mem = function (fn) { | |
| var called = 0; | |
| return function () { | |
| var args = Array.prototype.slice.call(arguments); | |
| called += 1; | |
| return { | |
| returned: fn.apply(null, args), | |
| called: called |
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
| /** | |
| * Returns a function that has a timeout of 'delay' seconds, | |
| * the timeout resets every time the function is called. However if | |
| * the (optional) except function returns true, the function will not be called. | |
| * | |
| * Useful for delaying and blocking keyboard events when a user is typing. | |
| * | |
| * @param {Number} delay timeout in milliseconds | |
| * @param {Function} fn the base function | |
| * @param {Function} except |