bankML-UIF / src /core /storage.ts
Gregory-L's picture
ultimate-bankml-ui 0.1.0: bankML behind the ultimate input field
ad1b8ec verified
Raw History Blame Contribute Delete
469 Bytes
// Every storage access is guarded: private windows and blocked site data throw.
export function loadJSON<T>(key: string, fallback: T): T {
try {
const raw = window.localStorage.getItem(key);
return raw ? (JSON.parse(raw) as T) : fallback;
} catch {
return fallback;
}
}
export function saveJSON(key: string, value: unknown): void {
try {
window.localStorage.setItem(key, JSON.stringify(value));
} catch {
/* storage unavailable */
}
}