@helpwave/hightide
Version:
helpwave's component and theming library
63 lines (62 loc) • 1.93 kB
JavaScript
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/util/storage.ts
var storage_exports = {};
__export(storage_exports, {
LocalStorageService: () => LocalStorageService,
SessionStorageService: () => SessionStorageService
});
module.exports = __toCommonJS(storage_exports);
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);
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
LocalStorageService,
SessionStorageService
});
//# sourceMappingURL=storage.js.map