Created
August 3, 2012 20:17
-
-
Save enjoylife/3251126 to your computer and use it in GitHub Desktop.
memoize snippet found
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
function memoizeConstantMethod(o, p) { | |
var f = o[p], mf; | |
var s = function(v) {return o[p]=v||mf}; | |
((mf = function() { | |
(s(function(){return value})).reset = mf.reset; | |
return value = f.call(this); | |
}).reset = s)(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment