Created
January 26, 2016 05:10
-
-
Save mistidoi/ef399920b1ea88b823b0 to your computer and use it in GitHub Desktop.
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 memoize; | |
memoize = function(func) { | |
var cache; | |
cache || (cache = {}); | |
return function() { | |
var key; | |
key = JSON.stringify(arguments); | |
if (cache[key]) { | |
return cache[key]; | |
} else { | |
return cache[key] = func.apply(this, arguments); | |
} | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment