UNPKG

session-storage-sync

Version:

sync session storage across multiple browser tabs from same origin

25 lines (24 loc) 529 B
export class StorageMechanism { _storage; constructor(storage) { this._storage = storage; } get length() { return this._storage.length; } get(key) { return JSON.parse(this._storage.getItem(key)); } set(key, value) { this._storage.setItem(key, JSON.stringify(value)); } remove(key) { this._storage.removeItem(key); } clear() { this._storage.clear(); } key(index) { return JSON.parse(this._storage.key(index)); } }