aboutsummaryrefslogtreecommitdiffstats
path: root/packages/website/ts/local_storage
diff options
context:
space:
mode:
Diffstat (limited to 'packages/website/ts/local_storage')
-rw-r--r--packages/website/ts/local_storage/local_storage.ts14
1 files changed, 14 insertions, 0 deletions
diff --git a/packages/website/ts/local_storage/local_storage.ts b/packages/website/ts/local_storage/local_storage.ts
index 20a533a91..569e262fc 100644
--- a/packages/website/ts/local_storage/local_storage.ts
+++ b/packages/website/ts/local_storage/local_storage.ts
@@ -26,6 +26,20 @@ export const localStorage = {
}
window.localStorage.removeItem(key);
},
+ getObject(key: string): object {
+ const item = localStorage.getItemIfExists(key);
+ if (item) {
+ try {
+ return JSON.parse(item);
+ } catch (err) {
+ return undefined;
+ }
+ }
+ return undefined;
+ },
+ setObject(key: string, value: object): void {
+ localStorage.setItem(key, JSON.stringify(value));
+ },
getAllKeys(): string[] {
if (!this.doesExist) {
return [];