refactor: clamp\storage dry

This commit is contained in:
2026-10-09 22:09:02 +05:00
parent d58f6c90be
commit 07c6475c21
15 changed files with 68 additions and 77 deletions
+12
View File
@@ -0,0 +1,12 @@
export function storage(): Storage | null {
return typeof localStorage === "undefined" ? null : localStorage;
}
// setItem throws in privacy modes; persistence is best-effort.
export function safeSetItem(key: string, value: string): void {
try {
storage()?.setItem(key, value);
} catch {
// ignore
}
}