(endpoint: string)
| 88 | } |
| 89 | |
| 90 | async clear(endpoint: string): Promise<void> { |
| 91 | const normalizedEndpoint = normalizeEndpoint(endpoint); |
| 92 | const cache = await this.readCacheFile(); |
| 93 | |
| 94 | if (!(normalizedEndpoint in cache.entries)) { |
| 95 | return; |
| 96 | } |
| 97 | |
| 98 | delete cache.entries[normalizedEndpoint]; |
| 99 | |
| 100 | if (Object.keys(cache.entries).length === 0) { |
| 101 | await rm(this.cacheFilePath, { force: true }).catch(() => undefined); |
| 102 | return; |
| 103 | } |
| 104 | |
| 105 | await this.writeCacheFile(cache); |
| 106 | } |
| 107 | |
| 108 | private async readCacheFile(): Promise<CacheFileShape> { |
| 109 | try { |
nothing calls this directly
no test coverage detected