ts-data-forge
    Preparing search index...
    • 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

      • R

        The return type of the function

      Parameters

      • fn: () => R

        The pure function to memoize

      Returns () => R

      A memoized version of the input function with the same signature

    • 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

      • Arg0
      • const RestArgs extends readonly unknown[]
      • R

        The return type of the function

      • K extends Primitive

        The primitive type used as the cache key (must be valid Map key)

      Parameters

      • fn: (arg0: Arg0, ...args: RestArgs) => R

        The pure function to memoize

      • argsToCacheKey: (arg0: Arg0, ...args: RestArgs) => K

        Function that converts arguments to a unique cache key. Optional for zero-argument functions.

      Returns (arg0: Arg0, ...args: RestArgs) => R

      A memoized version of the input function with the same signature