* Determine if a specific version of the given resource is cached anywhere within the SW, * and fetch it if so.
(url: NormalizedUrl, hash: string)
| 1165 | * and fetch it if so. |
| 1166 | */ |
| 1167 | lookupResourceWithHash(url: NormalizedUrl, hash: string): Promise<Response | null> { |
| 1168 | return ( |
| 1169 | Array |
| 1170 | // Scan through the set of all cached versions, valid or otherwise. It's safe to do such |
| 1171 | // lookups even for invalid versions as the cached version of a resource will have the |
| 1172 | // same hash regardless. |
| 1173 | .from(this.versions.values()) |
| 1174 | // Reduce the set of versions to a single potential result. At any point along the |
| 1175 | // reduction, if a response has already been identified, then pass it through, as no |
| 1176 | // future operation could change the response. If no response has been found yet, keep |
| 1177 | // checking versions until one is or until all versions have been exhausted. |
| 1178 | .reduce(async (prev, version) => { |
| 1179 | // First, check the previous result. If a non-null result has been found already, just |
| 1180 | // return it. |
| 1181 | if ((await prev) !== null) { |
| 1182 | return prev; |
| 1183 | } |
| 1184 | |
| 1185 | // No result has been found yet. Try the next `AppVersion`. |
| 1186 | return version.lookupResourceWithHash(url, hash); |
| 1187 | }, Promise.resolve<Response | null>(null)) |
| 1188 | ); |
| 1189 | } |
| 1190 | |
| 1191 | async lookupResourceWithoutHash(url: NormalizedUrl): Promise<CacheState | null> { |
| 1192 | await this.initialized; |
nothing calls this directly
no test coverage detected