/** See the top of this file. */ export declare class SettledCache { private readonly opts; private readonly values; private readonly inFlight; constructor(opts?: { /** Whether to keep this value; default: every fulfilled one. */ keep?: (value: V) => boolean; /** At most this many values, the oldest let go first. */ max?: number; }); /** The kept value for `key`, without waiting for anything. */ peek(key: K): { value: V; } | undefined; /** * The kept value, in a promise made for this caller; otherwise `load`, * kept when it settles. A caller passing the `scope` another caller is * loading under joins that load: one promise per key and scope. */ get(key: K, load: () => Promise, scope?: object): Promise; /** Keep `value` for `key`, as a settled load would. */ set(key: K, value: V): void; /** Forget the value for `key`: the next `get` loads again. */ delete(key: K): void; private loadsOf; } /** * `load`, made once its result is in and kept from then on: the value, not * the promise (see {@link SettledCache}). Until then every call loads, and a * rejection keeps nothing. */ export declare function settledOnce(load: () => Promise): () => Promise; /** Whether `err` is workerd refusing another request's promise or I/O. */ export declare function isCrossRequestError(err: unknown): boolean; /** * `load`, made once and kept from then on, for a load that must not be done * twice at once: building a server, a runtime, loading a module. * * Unlike {@link settledOnce}, callers that arrive while the first load is * still running join it, so it runs once. That is the one place a promise is * shared between requests, and so it is guarded: a caller whose joined load is * refused as another request's ({@link isCrossRequestError}) -- the request * that started it ended first -- loads again, from its own request. What is * kept is the value, never the promise, and a rejection keeps nothing. */ export declare function keptOnce(load: () => Promise): () => Promise;