class StorageAdapter { constructor(type) { if (type === "session") { this.storage = window.sessionStorage; } else if (type === "local") { this.storage = window.localStorage; } } setItem(key, value) { return this.storage.setItem(key, JSON.stringify(value)); } getItem(key) { const item = this.storage.getItem(key); if (item) { try { return JSON.parse(item); } catch (error) { return item; } } return null; } removeItem(key) { return this.storage.removeItem(key); } getStorage() { return this.storage; } get length() { return this.storage.length; } clear() { return this.storage.clear(); } key(index) { return this.storage.key(index); } } StorageAdapter.session = new StorageAdapter("session"); StorageAdapter.local = new StorageAdapter("local"); export { StorageAdapter };