()
| 49 | |
| 50 | /** Live star count, memoized per isolate with a TTL. null when unavailable. */ |
| 51 | export function getStars(): Promise<number | null> { |
| 52 | const now = Date.now(); |
| 53 | if (cached) { |
| 54 | const ttl = cached.value != null ? TTL_OK_MS : TTL_FAIL_MS; |
| 55 | if (now - cached.at < ttl) return Promise.resolve(cached.value); |
| 56 | } |
| 57 | if (inflight) return inflight; |
| 58 | inflight = fetchStars().then((value) => { |
| 59 | cached = { value, at: Date.now() }; |
| 60 | inflight = null; |
| 61 | return value; |
| 62 | }); |
| 63 | return inflight; |
| 64 | } |
nothing calls this directly
no test coverage detected