codetrix
Version:
A lightweight lodash-style utility library
16 lines (15 loc) • 468 B
TypeScript
/**
* Creates a memoized version of `fn`. The result of each call is cached
* based on the arguments provided.
*
* @template T - The function type
* @param fn - The function to memoize
* @returns A new memoized function
*
* @example
* const slowFn = (x: number) => x * 2;
* const memoized = memoize(slowFn);
* memoized(2); // Computed
* memoized(2); // Retrieved from cache
*/
export declare function memoize<T extends (...args: any[]) => any>(fn: T): T;