main repo

This commit is contained in:
Basilosaurusrex
2025-11-24 18:09:40 +01:00
parent b636ee5e70
commit f027651f9b
34146 changed files with 4436636 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
const FIVE_MINUTES = 5 * 60 * 1000;
const THIRTY_SECONDS = 30 * 1000;
export var PrefetchCacheEntryStatus;
(function(PrefetchCacheEntryStatus) {
PrefetchCacheEntryStatus["fresh"] = "fresh";
PrefetchCacheEntryStatus["reusable"] = "reusable";
PrefetchCacheEntryStatus["expired"] = "expired";
PrefetchCacheEntryStatus["stale"] = "stale";
})(PrefetchCacheEntryStatus || (PrefetchCacheEntryStatus = {}));
export function getPrefetchEntryCacheStatus(param) {
let { kind, prefetchTime, lastUsedTime } = param;
// if the cache entry was prefetched or read less than 30s ago, then we want to re-use it
if (Date.now() < (lastUsedTime != null ? lastUsedTime : prefetchTime) + THIRTY_SECONDS) {
return lastUsedTime ? "reusable" : "fresh";
}
// if the cache entry was prefetched less than 5 mins ago, then we want to re-use only the loading state
if (kind === "auto") {
if (Date.now() < prefetchTime + FIVE_MINUTES) {
return "stale";
}
}
// if the cache entry was prefetched less than 5 mins ago and was a "full" prefetch, then we want to re-use it "full
if (kind === "full") {
if (Date.now() < prefetchTime + FIVE_MINUTES) {
return "reusable";
}
}
return "expired";
}
//# sourceMappingURL=get-prefetch-cache-entry-status.js.map