The type of the resolved value of the managed promises.
Create a new Inflight instance.
Uses native Promise by default. Pass a custom Promise implementation if needed:
import AveAzul from "aveazul";
const inflight = new Inflight(AveAzul);
The type of the resolved value of the managed promises.
OptionalPromiseImpl: PromiseConstructor
Optional custom Promise implementation to use.
Protected Readonly_Map of inflight items by key
ReadonlyPromiseThe Promise implementation used by this instance
The number of inflight items.
Whether there are no inflight items.
Track a value under a key.
Optionalnow: numberIterate the tracked items as [key, record] pairs.
Prefer this over reaching for the internal map - it is what lets a caller sweep every in-progress entry, which is what item-queue's overdue-work watcher does.
Get the last check time (ms since epoch) for a key, or undefined.
Get the start time (ms since epoch) for a key, or undefined.
Elapsed ms since the last check for a key, or -1 if not found.
Optionalnow: numberGet or create a promise for a given key. If a promise for the key is already inflight, returns it. Otherwise, calls the provided factory to create a new promise, tracks it, and returns it.
Reset the last check time for a key, or for all inflight items if no key is given.
Optionalkey: RecordKeyOptionalnow: numberThis instance for chaining.
Elapsed ms since the start for a key, or -1 if not found.
Optionalnow: number
Inflight manages deduplication of asynchronous operations by key. It ensures only one promise per key is active at a time, returning the same promise for concurrent requests. Useful for avoiding duplicate network or resource-intensive calls.
Adds promise semantics to InflightStore; the keyed storage and time tracking are inherited, so there is one implementation of them (FJM-26).
Example