1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-09-09 01:09:54 +00:00

json & web search

This commit is contained in:
Laura
2025-08-11 00:15:58 +02:00
parent 5ae60e0f94
commit a8cbef7c7b
19 changed files with 374 additions and 59 deletions

View File

@@ -1,5 +1,7 @@
function storeValue(key, value) {
if (!value) {
/** biome-ignore-all lint/correctness/noUnusedVariables: utility */
function storeValue(key, value = false) {
if (value === null || value === undefined || value === false) {
localStorage.removeItem(key);
return;
@@ -11,14 +13,14 @@ function storeValue(key, value) {
function loadValue(key, fallback = false) {
const raw = localStorage.getItem(key);
if (!raw) {
if (raw === null) {
return fallback;
}
try {
const value = JSON.parse(raw);
if (!value) {
if (value === null) {
throw new Error("no value");
}