2a2fae8a97
This reverts commit bf9d90d80f.
21 lines
434 B
TypeScript
21 lines
434 B
TypeScript
|
|
export default class CacheUtils
|
|
{
|
|
map: Map<string, any> = new Map();
|
|
|
|
/**
|
|
* Get a cached value, or if not cached, cache it.
|
|
*
|
|
* @param name Name of the cached value
|
|
* @param callback Callback function
|
|
*/
|
|
public get(name: string, callback: () => any)
|
|
{
|
|
if (!this.map.has(name))
|
|
{
|
|
this.map.set(name, callback());
|
|
}
|
|
return this.map.get(name);
|
|
}
|
|
}
|