terrible/app/utils/singleton.js

10 lines
218 B
JavaScript
Raw Normal View History

2024-03-11 23:03:35 -05:00
export function singleton(key, value) {
global.__singletons ??= {};
global.__singletons[key] ??= value;
return global.__singletons[key];
}
singleton.reset = function (key) {
delete global.__singletons[key];
}