Skip to content

Instantly share code, notes, and snippets.

@sumanmukherjee03
Created March 8, 2013 16:59
Show Gist options
  • Save sumanmukherjee03/5117968 to your computer and use it in GitHub Desktop.
Save sumanmukherjee03/5117968 to your computer and use it in GitHub Desktop.
cache function
Function.prototype.cache = (function() {return {};})();
Function.prototype.setCache = (function() {
var self = this;
return function(key) {
if(!this.cache[key])
this.cache[key] = this.call(self, key);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment