Wrapper for localStorage

This commit is contained in:
infinite-persistence 2022-05-18 16:57:25 +08:00
parent b733215c5f
commit 5e3effc94d
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0

View file

@ -23,3 +23,15 @@ export function getLocalStorageSummary() {
return 'inaccessible';
}
}
const localStorageAvailable = isLocalStorageAvailable();
export function getLocalStorageItem(key) {
return localStorageAvailable ? window.localStorage.getItem(key) : undefined;
}
export function setLocalStorageItem(key, value) {
if (localStorageAvailable) {
window.localStorage.setItem(key, value);
}
}