(seed: Record<string, string> = {})
| 12 | import { readWhyAnswer, recordWhyAnswer, whyKey } from './why-store'; |
| 13 | |
| 14 | function memoryStore(seed: Record<string, string> = {}): KeyValueStore { |
| 15 | const map = new Map<string, string>(Object.entries(seed)); |
| 16 | return { |
| 17 | getItem: (key) => map.get(key) ?? null, |
| 18 | setItem: (key, value) => { |
| 19 | map.set(key, value); |
| 20 | }, |
| 21 | }; |
| 22 | } |
| 23 | |
| 24 | /** A store that refuses everything, as a browser with site data switched off does. */ |
| 25 | const refusing: KeyValueStore = { |