Created
October 24, 2017 17:39
-
-
Save Restuta/89193bd17e57c1339fdc4888b072d7ed 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
function memoize(foo) { | |
let cache = {} | |
return args => { | |
if(cache[args]) { | |
return cache[args] | |
} | |
const executionResult = foo(args) | |
cache = { | |
...cache, | |
[args]: executionResult | |
} | |
return executionResult | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment