Files
dinlo e0a986eb30 Initial commit
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-05-31 18:45:31 +08:00

20 lines
585 B
TypeScript

declare type QueueItem = () => void;
declare type IdleCallback = () => void | Promise<void>;
declare type AddCallback = () => void | Promise<void>;
interface Options {
concurrency?: number;
}
declare class PromiseQueue {
options: Required<Options>;
running: number;
queue: QueueItem[];
idleCallbacks: IdleCallback[];
constructor({ concurrency }?: Options);
clear(): void;
onIdle(callback: IdleCallback): () => void;
waitTillIdle(): Promise<void>;
add(callback: AddCallback): Promise<unknown>;
private processNext;
}
export { PromiseQueue };