File size: 230 Bytes
5b12974
 
 
 
 
 
1
2
3
4
5
6
7
export function singleton<T>(name: string, getValue: () => T): T {
  const thusly = globalThis as any;
  thusly.__core_singletons ??= {};
  thusly.__core_singletons[name] ??= getValue();
  return thusly.__core_singletons[name];
}