Files
bentopdf/src/js/utils/safe-storage.ts
T

26 lines
475 B
TypeScript

export const getStoredItem = (key: string): string | null => {
try {
return localStorage.getItem(key);
} catch {
return null;
}
};
export const setStoredItem = (key: string, value: string): boolean => {
try {
localStorage.setItem(key, value);
return true;
} catch {
return false;
}
};
export const removeStoredItem = (key: string): boolean => {
try {
localStorage.removeItem(key);
return true;
} catch {
return false;
}
};