Skip to content

Instantly share code, notes, and snippets.

@Msirkovsky
Created January 13, 2023 08:23
Show Gist options
  • Save Msirkovsky/e095c16d25b9c918abdb0ee565c89f72 to your computer and use it in GitHub Desktop.
Save Msirkovsky/e095c16d25b9c918abdb0ee565c89f72 to your computer and use it in GitHub Desktop.
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