Options
All
  • Public
  • Public/Protected
  • All
Menu

Module src/others/memoize

Index

Functions

Functions

Const memoize

  • memoize(fn: (...args: any[]) => any, cacheKeyGenerator?: (...args: any[]) => string): (...args: any[]) => any
  • Prevent expensive, repeat function calls by caching the result and returning the cached result when the cacheKey matches

    The cache key must be toString-able. The cache key will automatically default to the first argument of the memoized function, otherwise the cacheKeyGenerator can be used. The cacheKeyGenerator must be used when the first argument is an object, otherwise the cacheKey will be converted to '[object Object]' which could provided unexpected results

    Parameters

    • fn: (...args: any[]) => any

      The function to memoize

        • (...args: any[]): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    • Optional cacheKeyGenerator: (...args: any[]) => string
        • (...args: any[]): string
        • Parameters

          • Rest ...args: any[]

          Returns string

    Returns (...args: any[]) => any

      • (...args: any[]): any
      • Parameters

        • Rest ...args: any[]

        Returns any

Generated using TypeDoc