silphius/app/util/singleton.js
2024-09-21 06:24:26 -05:00

10 lines
218 B
JavaScript

export function singleton(key, value) {
global.__singletons ??= {};
global.__singletons[key] ??= value;
return global.__singletons[key];
}
singleton.reset = function (key) {
delete global.__singletons[key];
}