added doga

This commit is contained in:
szabomarton
2025-02-25 09:55:29 +01:00
parent 5174ab4cc4
commit 13254e5623
1149 changed files with 80161 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
import { WebStorage } from './WebStorage.js';
export declare class LocalStorage<T> extends WebStorage<T> {
constructor(key: string);
}

View File

@@ -0,0 +1,6 @@
import { WebStorage } from './WebStorage.js';
export class LocalStorage extends WebStorage {
constructor(key) {
super(key, localStorage);
}
}

View File

@@ -0,0 +1,4 @@
import { WebStorage } from './WebStorage.js';
export declare class SessionStorage<T> extends WebStorage<T> {
constructor(key: string);
}

View File

@@ -0,0 +1,6 @@
import { WebStorage } from './WebStorage.js';
export class SessionStorage extends WebStorage {
constructor(key) {
super(key, sessionStorage);
}
}

View File

@@ -0,0 +1,7 @@
import { SyncAdapter } from '../../core/Low.js';
export declare class WebStorage<T> implements SyncAdapter<T> {
#private;
constructor(key: string, storage: Storage);
read(): T | null;
write(obj: T): void;
}

View File

@@ -0,0 +1,18 @@
export class WebStorage {
#key;
#storage;
constructor(key, storage) {
this.#key = key;
this.#storage = storage;
}
read() {
const value = this.#storage.getItem(this.#key);
if (value === null) {
return null;
}
return JSON.parse(value);
}
write(obj) {
this.#storage.setItem(this.#key, JSON.stringify(obj));
}
}