• 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)

      The function to memoize

        • (...args): any
        • Parameters

          • Rest ...args: any[]

          Returns any

    • Optional cacheKeyGenerator: ((...args) => string)

      Optional. Arguments passed in are supplied by the function to be memoized

        • (...args): string
        • Parameters

          • Rest ...args: any[]

          Returns string

    Returns ((...args) => any)

      • (...args): any
      • Parameters

        • Rest ...args: any[]

        Returns any

Generated using TypeDoc