(url: string)
| 24 | constructor(private cacheDir: string) {} |
| 25 | |
| 26 | async fetch(url: string): Promise<string> { |
| 27 | return this.cached(url, async () => { |
| 28 | const response = await fetch(url); |
| 29 | if (!response.ok) { |
| 30 | throw new Error(`HTTP ${response.status} ${response.statusText}`); |
| 31 | } |
| 32 | return response.text(); |
| 33 | }); |
| 34 | } |
| 35 | |
| 36 | async cached(key: string, fresh: () => Promise<string>): Promise<string> { |
| 37 | this.usedKeys.add(this.cacheKey(key)); |
no test coverage detected