Returns a memoized version of fn that caches results by serialized arguments. Only suitable for pure functions with JSON-serializable arguments.
fn
The function to memoize.
const expensiveCalc = memoize((n: number) => n * n)expensiveCalc(4) // computed: 16expensiveCalc(4) // cached: 16 Copy
const expensiveCalc = memoize((n: number) => n * n)expensiveCalc(4) // computed: 16expensiveCalc(4) // cached: 16
Returns a memoized version of
fnthat caches results by serialized arguments. Only suitable for pure functions with JSON-serializable arguments.