@am92/securities-utility
Version:
A utility package for securities applications
19 lines (18 loc) • 855 B
TypeScript
/**
* Represents any function with any number of arguments and return type.
*/
type AnyFunction = (...args: any[]) => any;
/**
* @ignore
* Memoizes a function by caching its results based on the arguments provided.
* Improves performance for functions with expensive computations by avoiding redundant calculations for the same inputs.
*
* The cache uses a least recently used (LRU) strategy, where the least recently accessed item is evicted when the cache exceeds its size limit.
*
* @template T - The type of the function to be memoized.
* @param {T} fn - The function to be memoized.
* @param {number} [cacheLimit=100] - The maximum number of cached results. Defaults to 100.
* @returns {T} - The memoized version of the input function.
*/
export declare function memoize<T extends AnyFunction>(fn: T, cacheLimit?: number): T;
export {};