Context-Store-LLM / apps /webapp /app /utils /singleton.ts
BarisT
Clean Context Store for HuggingFace deployment
5b12974
Raw History Blame Contribute Delete
230 Bytes
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];
}