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
| _.once = function(func) { | |
| var alreadyCalled = false, | |
| result; | |
| return function() { | |
| if(!alreadyCalled) { | |
| result = func.apply(this, arguments); | |
| alreadyCalled = true; | |
| } | |
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 call = function(fn, context) { | |
| var args = Array.prototype.slice.call(arguments, 2).join(‘,’), | |
| result; | |
| context.fn = fn; | |
| result = eval(“context.fn(“+ args +”)”); | |
| delete this.fn; | |
| return result; | |
| }; |
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
| _.first = function(array, n) { | |
| if (n === undefined) { | |
| return array[0]; | |
| } | |
| return slice.call(array, 0, n); | |
| }; |
NewerOlder