/** * A queue that executes async tasks in order like mutex and semaphore methodology * * @example * ```ts * const queue = new AsyncQueue(); * * function longTask() { * queue.push('longTaskId', async () => { * // ... * }); * } * ``` */ export declare class AsyncQueue { /** * A record of task IDs and their corresponding last queued task promises. */ private queue__; /** * Push a async task to the queue. * * @param taskId task id * @param task async task * @returns A promise that resolves when the task is done. * * @example * ```typescript * const queue = new AsyncQueue(); * * function longTask() { * queue.push('longTaskId', async () => { * // ... * }); * ``` */ push(taskId: string, task: () => Promise): Promise; /** * Check if the task running in the queue. * * @param taskId task id * @returns true if the task is running, otherwise false. * @example * ```typescript * if (queue.isRunning('longTaskId')) { * // ... * } * ``` */ isRunning(taskId: string): boolean; /** * Wait for the all tasks in the queue to finish. * * @param taskId task id * @returns A promise that resolves when all tasks are done. * @example * ```typescript * await queue.waitForFinish('longTaskId'); * ``` */ waitForFinish(taskId: string): Promise; /** * Wait for the all tasks in the queue to finish. * @returns A promise that resolves when all tasks are done. * @example * ```typescript * await queue.waitForAllFinish(); * ``` */ waitForAllFinish(): Promise; } //# sourceMappingURL=main.d.ts.map