memoize

Creates a function that memoizes the result of a given function.

The cache key is determined by the resolver or by the arguments from the function call.

Options:

  • resolver A function that determines the cache key based on the arguments provided.
  • ttl the time to live for the cache entries in milliseconds.

Properties:

  • cache The cache is an instance of Map and can be used to clear or inspect the cache. It can be replaced by a custom cache that matches the Map interface.

This function can be used as a decorator with decMemoize.

Example