mirror of
https://github.com/eliasstepanik/core.git
synced 2026-01-11 17:08:27 +00:00
7 lines
230 B
TypeScript
7 lines
230 B
TypeScript
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];
|
|
}
|