| 21 | import type { UserPreferences } from "@/common/config/schemas/userPreferences"; |
| 22 | |
| 23 | class MemoryStorage implements Storage { |
| 24 | private values = new Map<string, string>(); |
| 25 | |
| 26 | get length() { |
| 27 | return this.values.size; |
| 28 | } |
| 29 | |
| 30 | clear(): void { |
| 31 | this.values.clear(); |
| 32 | } |
| 33 | |
| 34 | getItem(key: string): string | null { |
| 35 | return this.values.get(key) ?? null; |
| 36 | } |
| 37 | |
| 38 | key(index: number): string | null { |
| 39 | return Array.from(this.values.keys())[index] ?? null; |
| 40 | } |
| 41 | |
| 42 | removeItem(key: string): void { |
| 43 | this.values.delete(key); |
| 44 | } |
| 45 | |
| 46 | setItem(key: string, value: string): void { |
| 47 | this.values.set(key, value); |
| 48 | } |
| 49 | |
| 50 | setJSON(key: string, value: unknown): void { |
| 51 | this.setItem(key, JSON.stringify(value)); |
| 52 | } |
| 53 | } |
| 54 | |
| 55 | async function waitUntil(assertion: () => void): Promise<void> { |
| 56 | const deadline = Date.now() + 1000; |
nothing calls this directly
no outgoing calls
no test coverage detected