@utilify/core
Version:
Modern, strongly typed, and safe utility function library for JavaScript and TypeScript. Includes type checking, manipulation of arrays, objects, strings, dates, colors, numbers, regular expressions, and more. Compatible with Browser, Node.js, Deno, and B
23 lines • 869 B
TypeScript
/**
* @callback MemoCallback
* @param {...any} args
* @returns {any}
*/
/**
* @callback MemoSerializer
* @param {any[]} args
* @returns {string}
*/
/**
* Memoizes a function, caching results by arguments.
* @template T
* @param {MemoCallback} callback - The function to memoize.
* @param {{cacheTimeout?: number, serializer?: MemoSerializer}} [options={serializer: JSON.stringify}] - Memoization options.
* @returns {(...args: Parameters<T>) => ReturnType<T>} The memoized function.
* @throws {TypeError} If callback or serializer is not a function, or cacheTimeout is not a number.
*/
export default function memo<T extends (...args: any[]) => any>(callback: T, { cacheTimeout, serializer }?: {
cacheTimeout?: number;
serializer?: (args: Parameters<T>) => string;
}): (...args: Parameters<T>) => ReturnType<T>;
//# sourceMappingURL=memo.d.ts.map