(key: string, holds: (snapshot: string) => boolean)
| 188 | |
| 189 | // an answer stored for the key whose snapshot still holds |
| 190 | get(key: string, holds: (snapshot: string) => boolean): unknown { |
| 191 | const stored = this.read(`a-${key}`) as |
| 192 | | { snapshot: string; answer: unknown } |
| 193 | | undefined |
| 194 | if (stored && isHash(stored.snapshot) && holds(stored.snapshot)) |
| 195 | return stored.answer |
| 196 | } |
| 197 | |
| 198 | set(key: string, answer: unknown, snapshot: string): void { |
| 199 | this.write(`a-${key}`, JSON.stringify({ snapshot, answer })) |