export type ConcurrentOptions = { /** Maximum number of calls in flight, a positive integer. */ limit: number; /** Aborting rejects with `signal.reason` once in-flight calls have settled. */ signal?: AbortSignal; }; export type PrefetchOptions = { /** Maximum number of fetches started but not yet yielded, a positive integer. */ window: number; /** Aborting makes the generator throw `signal.reason` and aborts outstanding fetches. */ signal?: AbortSignal; }; /** * Map items with at most `limit` calls in flight, resolving results in input order. * * On the first rejection (or outer abort) the signal passed to running calls is aborted, no new * call starts, in-flight calls are awaited, then the promise rejects with the first error * (or the outer signal's reason). */ export declare function mapConcurrent(items: Iterable, fn: (item: T, index: number, signal: AbortSignal) => Promise, options: ConcurrentOptions): Promise>; /** * Hedged failover: ask up to `limit` items concurrently and resolve with the result of the * earliest item in list order that returns a non-null value, once every earlier item has settled * as a miss (null, undefined or rejection). * * Resolves `null` when no item hits, except when every item rejected (and there is at least one * item): then it rejects with an AggregateError of all the errors in list order. The signals of * the other items are aborted once decided, and the promise settles after in-flight calls have. * Outer abort rejects with `signal.reason`. */ export declare function firstInOrder(items: Iterable, fn: (item: T, index: number, signal: AbortSignal) => Promise, options: ConcurrentOptions): Promise; /** * Yield `fetch(0..count-1)` results strictly in index order, keeping up to `window` fetches * started but not yet yielded. * * An error in fetch `i` is thrown when the consumer reaches `i`. When the generator ends for any * reason (error, `break`, `return`, outer abort) outstanding fetches are aborted and awaited. */ export declare function prefetchOrdered(count: number, fetch: (index: number, signal: AbortSignal) => Promise, options: PrefetchOptions): AsyncGenerator;