/** * @typedef {object} CachedOptions * @property {number} [ttl=Infinity] Milliseconds a Cache-API entry is * considered fresh. After expiry the next call re-fetches. Default * is `Infinity` * @property {string} [cacheName='pota-cache-v1'] The Cache API bucket * to read/write. Default is `'pota-cache-v1'` * @property {(r: Response) => unknown} [parse] Default is `r => * r.json()`. Applied to the cached or freshly-fetched `Response` to * produce the resolved value. */ /** * Cached `fetch`. Three layers: concurrent in-flight dedup, Cache API * persistence with per-entry TTL, then network fetch. Cache entries * are stamped with `x-cached-at` so TTL works without a sidecar * index. Successful results are removed from the in-flight map so * later calls (past TTL) can refresh; failed fetches are removed too * so they can be retried. * * @template T * @param {string} url * @param {CachedOptions} [opts] * @returns {Promise} * @url https://pota.quack.uy/use/cached */ export function cached(url: string, opts?: CachedOptions): Promise; export type CachedOptions = { /** * Milliseconds a Cache-API entry is * considered fresh. After expiry the next call re-fetches. Default * is `Infinity` */ ttl?: number; /** * The Cache API bucket * to read/write. Default is `'pota-cache-v1'` */ cacheName?: string; /** * Default is `r => * r.json()`. Applied to the cached or freshly-fetched `Response` to * produce the resolved value. */ parse?: (r: Response) => unknown; }; //# sourceMappingURL=cached.d.ts.map