()
| 2 | * Estimates the size of localStorage usage in bytes. |
| 3 | */ |
| 4 | export function getLocalStorageSize(): number { |
| 5 | if (typeof window === 'undefined' || !window.localStorage) { |
| 6 | return 0; |
| 7 | } |
| 8 | |
| 9 | let total = 0; |
| 10 | for (const key in window.localStorage) { |
| 11 | if (window.localStorage.hasOwnProperty(key)) { |
| 12 | total += window.localStorage[key].length + key.length; |
| 13 | } |
| 14 | } |
| 15 | return total; |
| 16 | } |
| 17 | |
| 18 | /** |
| 19 | * Attempts to free up localStorage space by removing DocSearch-related items |
no outgoing calls
no test coverage detected