superflected
Version:
A port of ActiveSupport's inflector to Node.js
8 lines (7 loc) • 444 B
TypeScript
/** Wrap a given function in a cache that is off by default */
export declare const cacheable: <T extends (...args: any[]) => any>(fn: T, getCacheKey?: (...args: Parameters<T>) => string) => T & {
/** A cache that stores results of the function. Not used by default. */
cache: Map<string, ReturnType<T>>;
/** Populate the cache with the result of calling the function. */
populate: (...args: Parameters<T>) => ReturnType<T>;
};