This file contains 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
// http://jsperf.com/function-proto-bind/3 | |
Function.prototype.bind = function(that){ | |
var self = this, | |
args = arguments.length > 1 ? Array.slice(arguments, 1) : null, | |
F = function(){}; | |
var bound = function(){ | |
var context = that, length = arguments,length; | |
if (this instanceof bound){ | |
F.prototype = self.prototype; |
This file contains 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
// A memoize function to store function results of heavy functions | |
// http://jsfiddle.net/arian/UQsEA/1/ | |
(function(slice){ | |
Function.prototype.memoize = function(hashFn, bind){ | |
var cache = {}, self = bind ? this.bind(bind) : this, hashFn = hashFn || JSON.stringify; | |
return function(){ | |
return ((key = hashFn(slice.call(arguments))) in cache) |