UNPKG

@expressive-tea/plugin

Version:

A Plugin Engine for Expressive Tea Framework.

32 lines (31 loc) 1.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.StorageManager = void 0; const classStorage = new WeakMap(); const propertiesStorage = new WeakMap(); class StorageManager { static set(key, value, target, propertyKey) { if (propertyKey) { const targetPropertiesStorage = propertiesStorage.get(target); targetPropertiesStorage.set(propertyKey, value); } else { classStorage.set(target, value); propertiesStorage.set(target, new WeakMap()); } } static get(key, target, propertyKey) { if (!classStorage.has(target)) { return; } if (propertyKey) { if (!propertiesStorage.has(target)) { return; } const propertyStorage = propertiesStorage.get(target); return propertyStorage.get(propertyKey); } return classStorage.get(target); } } exports.StorageManager = StorageManager;