Creates a memoized version of a function that caches results based on input
arguments.
The memoized function stores results in an internal Map and returns cached
values for repeated calls with the same arguments. This can significantly
improve performance for expensive computations or I/O operations.
Important considerations:
The cache grows unbounded - consider memory implications for long-running
applications
Cache keys must be primitives (string, number, boolean, symbol, null,
undefined, bigint)
Object arguments require careful key generation to ensure uniqueness
Pure functions only - memoizing functions with side effects can lead to bugs
Type Parameters
constAextendsreadonlyunknown[]
The tuple type of the function arguments
R
The return type of the function
KextendsPrimitive
The primitive type used as the cache key (must be valid Map
key)
Creates a memoized version of a function that caches results based on input arguments.
The memoized function stores results in an internal Map and returns cached values for repeated calls with the same arguments. This can significantly improve performance for expensive computations or I/O operations.
Important considerations: