@helpwave/hightide
Version:
helpwave's component and theming library
38 lines • 857 B
JavaScript
// src/util/storage.ts
var StorageService = class {
// this seems to be a bug in eslint as 'paramter-properties' is a special syntax of typescript
constructor(storage) {
this.storage = storage;
}
get(key) {
const value = this.storage.getItem(key);
if (value === null) {
return null;
}
return JSON.parse(value);
}
set(key, value) {
this.storage.setItem(key, JSON.stringify(value));
}
delete(key) {
this.storage.removeItem(key);
}
deleteAll() {
this.storage.clear();
}
};
var LocalStorageService = class extends StorageService {
constructor() {
super(window.localStorage);
}
};
var SessionStorageService = class extends StorageService {
constructor() {
super(window.sessionStorage);
}
};
export {
LocalStorageService,
SessionStorageService
};
//# sourceMappingURL=storage.mjs.map