Created
January 13, 2023 08:23
-
-
Save Msirkovsky/e095c16d25b9c918abdb0ee565c89f72 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 = new Map() | |
function compute(... args) { | |
const key = JSON.stringify({...args}) | |
if (memoized.has(key)) | |
{ | |
return memoized.get(key) | |
} | |
else { | |
const value = carrySlowComputation(...args) | |
memoized[key] = value | |
return value | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment