memoize
Returns a memoized version of the function that caches results.
Cache keys are derived via JSON.stringify; undefined arguments are
correctly distinguished from null. Arguments that are not JSON-serializable
(functions, symbols, class instances, circular references) produce a
null-equivalent key and are not supported.
Available since v1.9.0
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
func | function | The function to memoize |
options | MemoizeOptions | Optional settings (e.g. `maxSize` to cap memory usage) (optional) |
Returns
Section titled “Returns”function — The memoized function
Examples
Section titled “Examples”Cache function results
Section titled “Cache function results”The underlying function is only called once for the same arguments.
Related Types
Section titled “Related Types”MemoizeOptions
Section titled “MemoizeOptions”Options for memoize.
