(id: string, html: string)
| 16 | const store = new Map<string, StoredPreview>(); |
| 17 | |
| 18 | export function storePreview(id: string, html: string): Date { |
| 19 | if (store.size >= MAX_STORE_SIZE) { |
| 20 | const oldest = store.keys().next().value; |
| 21 | if (oldest) store.delete(oldest); |
| 22 | } |
| 23 | const expiresAt = Date.now() + PREVIEW_TTL_MS; |
| 24 | store.set(id, { html, expiresAt }); |
| 25 | return new Date(expiresAt); |
| 26 | } |
| 27 | |
| 28 | export function getPreview(id: string): string | null { |
| 29 | const entry = store.get(id); |
no test coverage detected