()
| 12 | } |
| 13 | |
| 14 | public async get() { |
| 15 | if (!CURRENT_CACHES.has(this.cacheName)) { |
| 16 | return ''; |
| 17 | } |
| 18 | |
| 19 | try { |
| 20 | const request = new Request(`https://fake.cache/${this.cacheName}`); |
| 21 | const cache = await caches.open(this.cacheName); |
| 22 | const response = await cache.match(request); |
| 23 | |
| 24 | if (response) { |
| 25 | return response.text(); |
| 26 | } |
| 27 | } catch (error) { |
| 28 | console.error(error); |
| 29 | |
| 30 | return FALLBACK_CACHE.get(this.cacheName) || ''; |
| 31 | } |
| 32 | |
| 33 | return ''; |
| 34 | } |
| 35 | |
| 36 | public async set(value: string) { |
| 37 | if (!CURRENT_CACHES.has(this.cacheName)) { |
no test coverage detected