2021-12-07 15:48:09 +01:00
|
|
|
export function isLocalStorageAvailable() {
|
|
|
|
try {
|
|
|
|
return Boolean(window.localStorage);
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export function isSessionStorageAvailable() {
|
|
|
|
try {
|
|
|
|
return Boolean(window.sessionStorage);
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2022-02-22 16:11:22 +01:00
|
|
|
|
|
|
|
export function getLocalStorageSummary() {
|
|
|
|
try {
|
|
|
|
const count = window.localStorage.length;
|
|
|
|
const estimatedSize = JSON.stringify(window.localStorage).length;
|
|
|
|
return `${count} items; ${estimatedSize} bytes`;
|
|
|
|
} catch (e) {
|
|
|
|
return 'inaccessible';
|
|
|
|
}
|
|
|
|
}
|