@appsemble/utils
Version:
Utility functions used in Appsemble internally
12 lines (11 loc) • 549 B
TypeScript
/**
* Create a function for memoizing values.
*
* The cache accepts a factory function which is used for creating a value. If cache is called with
* the value, the factory is called and the returned value is memoized. If the cache is called with
* the same value again, the memoized value is returned.
*
* @param factory The function that generats new values if necessary.
* @returns A getter funcion which returns the generated or memoized value.
*/
export declare function objectCache<T, K = string>(factory: (id: K) => T): (id: K) => T;