Created
June 21, 2017 05:04
-
-
Save wdiasvargas/47c5c42c0adc885a312eda462822188d to your computer and use it in GitHub Desktop.
memoization
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
/** | |
* Created in 20/06/2017. | |
* Author: William Dias Vargas | |
* Github: @wdiasvargas | |
*/ | |
"use strict"; | |
export default (fn, cache = {}) => (x) => (x in cache) ? cache[x] : cache[x] = fn(x); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment