Created
March 18, 2017 10:44
-
-
Save lusan/7b6ed2bc0d41e9e7a6004e879c7ec4e8 to your computer and use it in GitHub Desktop.
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
/* | |
This piece has been taken from React.js Conf 2015 - Immutable Data and React | |
*/ | |
function memoize(fn) { | |
var prevArg; | |
var prevResult; | |
return function(arg) { | |
return arg === prevArg ? | |
prevResult : | |
(prevArg = arg, | |
prevResult = fn.call(this, arg)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment