(storage: Storage, key: string, value: string)
| 141 | } |
| 142 | |
| 143 | function write(storage: Storage, key: string, value: string) { |
| 144 | try { |
| 145 | storage.setItem(key, value) |
| 146 | cacheSet(key, value) |
| 147 | return true |
| 148 | } catch (error) { |
| 149 | if (!quota(error)) throw error |
| 150 | } |
| 151 | |
| 152 | try { |
| 153 | storage.removeItem(key) |
| 154 | cacheDelete(key) |
| 155 | storage.setItem(key, value) |
| 156 | cacheSet(key, value) |
| 157 | return true |
| 158 | } catch (error) { |
| 159 | if (!quota(error)) throw error |
| 160 | } |
| 161 | |
| 162 | const ok = evict(storage, key, value) |
| 163 | return ok |
| 164 | } |
| 165 | |
| 166 | function snapshot(value: unknown) { |
| 167 | return JSON.parse(JSON.stringify(value)) as unknown |
no test coverage detected