Private ReadonlypendingPending tasks keyed by cache key. Map insertion order IS the FIFO order;
re-enqueuing a key coalesces (the latest task wins and moves to newest).
PrivatependingPrivatespeculativeCount and bytes of the speculative subset of pending.
PrivatespeculativePrivate ReadonlyinCurrently-running task promises (for drain()).
PrivatedroppedPrivatedroppedPrivatepumpingPrivate ReadonlyconcurrencyPrivate ReadonlymaxPrivate ReadonlymaxPrivate StaticresolveResolve one configured limit: finite, floored, at least 1. All three go
through here because Math.max(1, Math.floor(NaN)) is NaN, and each limit
fails differently and silently on a NaN — size < NaN is false, so a
non-finite concurrency means the pump never starts a task (total L2
write loss) while a non-finite maxDepth/maxBytes simply removes that
bound. Every one of them is reachable through MultiLevelCachingStore's
opfsWrite* options, which bypass the config validators.
Schedule a write. Returns synchronously; the task runs in the background
when a concurrency slot frees. Re-enqueuing the same key replaces its
pending task (coalesce, keep-latest; the entry keeps the higher of the two
priorities). Past maxDepth or maxBytes the overflow policy in the
module docstring decides what goes: speculative writes before demand ones,
and otherwise this arrival.
PrivateoverPrivateenforceRestore both caps after arrivalKey was (re-)inserted. Both held before
the insert, so this removes only what the arrival pushed over.
PrivateevictionWhether evicting speculative writes can ever make room for arrival:
false when the arrival plus the pending writes that are NOT evictable
(every demand write, and the arrival itself) already exceed a cap. Checked
first so a hopeless arrival never discards speculative work for nothing.
PrivateoldestPrivateputPrivatetakePrivatedropDiscard a pending write and count it. Best-effort tier: L1 still holds it.
PrivatecountPrivatepumpStart tasks up to the concurrency cap.
Drop all pending (not-yet-started) tasks. In-flight tasks continue — the caller neutralizes their effect via its own staleness guard. Used on cache invalidation / dispose.
Await every pending + in-flight task to finish. Primarily for tests and an
optional teardown flush; the queue otherwise self-drains via pump().
A per-instance bounded-concurrency FIFO write queue with per-key coalescing. Unlike the page-wide gates (
utils/fetch-concurrency.ts, and the OPFS read gate onutils/async-gate.ts), which hold every waiter until a slot frees, this one is per-instance, configurable, and bounded by both task count and retained bytes: past its bounds it DROPS writes instead of queuing them. It has no abort exit — a queued task re-checks staleness when it runs (see the module doc).utils/README.mdtabulates what each queue honours.