(displayName = null, isRefresh = false, {priority = FOREGROUND_PRIORITY} = {})
| 183 | const metadata = await getMetadataBatch([displayName], isRefresh, {priority}); |
| 184 | return metadata[displayName] ?? metadataWithLatestYear({}); |
| 185 | } |
| 186 | |
| 187 | export async function getMetadataBatch(displayNames, isRefresh = false, {priority = FOREGROUND_PRIORITY} = {}) { |
| 188 | const uniqueDisplayNames = [...new Set(displayNames)].filter(Boolean); |
| 189 | const requestEpoch = getCacheEpoch(); |
| 190 | const entries = await Promise.all(uniqueDisplayNames.map((displayName) => ( |
| 191 | readCacheEntry(metadataCacheKey(displayName), {legacyFields: ["result"], requestEpoch}) |
| 192 | ))); |
| 193 | if (requestEpoch !== getCacheEpoch()) { |
| 194 | return {}; |
| 195 | } |
| 196 | |
| 197 | const cachedMetadata = Object.fromEntries(uniqueDisplayNames.flatMap((displayName, index) => ( |
| 198 | entries[index] ? [[displayName, metadataWithLatestYear(entries[index].value)]] : [] |
| 199 | ))); |
| 200 | const expiredDisplayNames = uniqueDisplayNames.filter((displayName, index) => ( |
| 201 | isCacheEntryExpired(entries[index], isRefresh) |
| 202 | )); |
no test coverage detected