UNPKG

@clawject/di

Version:

<p align="center"> <a href="https://clawject.com/" target="_blank"><img src="https://clawject.com/img/logo.svg" align="center" alt="Clawject Logo" width="120" height="120" /></a> </p>

43 lines (42 loc) 1.14 kB
"use strict"; var _a; Object.defineProperty(exports, "__esModule", { value: true }); exports.ObjectStorage = void 0; class ObjectStorage { static has(key) { return this.store.has(key); } static get(key) { return this.store.get(key) ?? null; } static getOrSetIfNotPresent(key, defaultValue) { if (!this.store.has(key)) { this.store.set(key, defaultValue); } return this.store.get(key); } static set(key, value) { this.store.set(key, value); } static clear() { this.store.clear(); } } exports.ObjectStorage = ObjectStorage; _a = ObjectStorage; //NEVER CHANGE THIS VALUE ObjectStorage.StorageSymbol = Symbol.for('____ClawjectObjectStorage_76d37f0680b145159b563058a6cc0101____'); ObjectStorage.store = (() => { const store = globalThis[_a.StorageSymbol]; if (store) { return store; } const newStore = new Map(); Object.defineProperty(globalThis, _a.StorageSymbol, { enumerable: false, value: newStore, configurable: false, writable: false, }); return newStore; })();