/** * PromisePool limits the number of concurrent executions for any given task. * * @example * ```ts * * const pool = new PromisePool(4); * * for (let idx = 0; idx < 7) { * // Runs the fetch request 4 times, * // halting on the 5th call. * // Waits until at least 1 or more promise resolves * // before resolving * await pool.add(() => { * return fetch(SOME_URL).then((r) => r.json()); * }); * } * ``` */ export declare class PromisePool { private readonly concurrency; private pendingTasks; private activeTasks; private drainScheduled; constructor(concurrency: number); private runTask; private scheduleDrain; private drain; /** * Adds a task to the pool. * @param task The task to add to the pool. */ add(task: () => Promise): Promise; }