Last active
January 20, 2019 11:53
-
-
Save ufocoder/3ea23f8414c0cf0320f96134023640b5 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
const memoized = fn => { | |
const cache = new WeakMap() | |
return (...args) => { | |
if (!cache.has(args)) { | |
cache.set(args, fn(...args)) | |
} | |
return cache.get(args) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment