mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-26 07:39:59 -07:00
git: reset
This commit is contained in:
19
app/src/scripts/utils/storage.ts
Normal file
19
app/src/scripts/utils/storage.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
export function saveToStorage(key?: string, value?: string | boolean) {
|
||||
if (key) {
|
||||
value !== undefined && value !== null
|
||||
? localStorage.setItem(key, String(value))
|
||||
: localStorage.removeItem(key);
|
||||
}
|
||||
}
|
||||
|
||||
export function readBooleanFromStorage(key: string) {
|
||||
const saved = localStorage.getItem(key);
|
||||
if (saved) {
|
||||
return isSerializedBooleanTrue(saved);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export function isSerializedBooleanTrue(serialized: string) {
|
||||
return serialized === "true" || serialized === "1";
|
||||
}
|
||||
Reference in New Issue
Block a user