()
| 135 | } |
| 136 | |
| 137 | function createMemoryStorage(): Storage { |
| 138 | const data = new Map<string, string>(); |
| 139 | return { |
| 140 | get length() { |
| 141 | return data.size; |
| 142 | }, |
| 143 | clear() { |
| 144 | data.clear(); |
| 145 | }, |
| 146 | getItem(key: string) { |
| 147 | return data.get(key) ?? null; |
| 148 | }, |
| 149 | key(index: number) { |
| 150 | return Array.from(data.keys()).at(index) ?? null; |
| 151 | }, |
| 152 | removeItem(key: string) { |
| 153 | data.delete(key); |
| 154 | }, |
| 155 | setItem(key: string, value: string) { |
| 156 | data.set(key, String(value)); |
| 157 | }, |
| 158 | }; |
| 159 | } |
| 160 | |
| 161 | function installStorage(storage: Storage): void { |
| 162 | Object.defineProperty(globalThis, 'localStorage', { |
no outgoing calls
no test coverage detected