mirror of
https://github.com/Ku6epXBOCTuK/easy-png-tools.git
synced 2026-11-13 17:08:20 +00:00
refactor: clamp\storage dry
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user