import { RunnerDuration, RunnerEvents, RunnerHooks, RunnerOptions, TasksCount, TasksWithDone, TaskWithDone } from "./Interface"; import { Task, Tasks } from "./Task"; export declare class TaskRunner { #private; constructor(options?: Partial>); /** * Returns the concurrency of the runner. */ get concurrency(): number; /** * Get whether the runner is busy executing tasks or not. */ get busy(): boolean; /** * Get whether the runner is paused or not. */ get paused(): boolean; /** * Get whether the runner is destroyed or not. */ get destroyed(): boolean; /** * Get the counts for the runner */ get count(): TasksCount; get duration(): RunnerDuration; /** * Get the list of tasks of the runner. */ get tasks(): { completed: Tasks; pending: Tasks; running: Tasks; all: Task[]; }; /** * Start task execution. */ start(): boolean; /** * Pause task execution. */ pause(): boolean; /** * Destroy a runner instance. This will ensure that the current instance is marked as dead, and no additional tasks are run. * * This does not affect currently running tasks. */ destroy(): void; /** * Set the concurrency value */ setConcurrency(concurrency: number): void; /** * Add a single task to the end of the list. * * ```ts * console.log(runner.tasks.pending) // [] * runner.add(t1) * console.log(runner.tasks.pending) // [t1] * ``` */ add(task: TaskWithDone, prepend?: boolean): void; /** * Add a single task to the beginning of the list. * * ```ts * console.log(runner.tasks.pending) // [t1, t2, t3] * runner.addFirst(t4) * console.log(runner.tasks.pending) // [t4, t1, t2, t3] * ``` */ addFirst(task: TaskWithDone): void; /** * Add a single task at a particular index. * * ```ts * console.log(runner.tasks) // [t1, t2, t3, t4, t5, t6] * runner.addAt(1, t) * console.log(runner.tasks.pending) // [t1, t7, t2, t3, t4, t5, t6] * ``` */ addAt(index: number, task: TaskWithDone): void; /** * Add multiple tasks to the end of the list. * * ```ts * console.log(runner.tasks) // [t1, t2, t3, t4, t5, t6] * runner.addMultiple([t7, t8, t9, t10, t11, t12]) * console.log(runner.tasks.pending) // [t1, t2, t4, t5, t6, t7, t8, t9, t10, t11, t12] * ``` */ addMultiple(tasks: TasksWithDone, prepend?: boolean): void; /** * Add multiple tasks to the beginning of the list. * * ```ts * console.log(runner.tasks) // [t1, t2, t3, t4, t5, t6] * runner.addMultiple([t7, t8, t9, t10, t11, t12]) * console.log(runner.tasks.pending) // [t1, t2, t4, t5, t6, t7, t8, t9, t10, t11, t12] * ``` */ addMultipleFirst(tasks: TasksWithDone): void; /** * Remove the last pending task in the list. * * ```ts * runner.addMultiple([t1, t2, t3, t4, t5, t6]) * runner.remove() * console.log(runner.tasks.pending) // [t1, t2, t3, t4, t5] * ``` */ remove(first?: boolean): void; /** * Remove the first pending task in the list. * * ```ts * runner.addMultiple([t1, t2, t3, t4, t5, t6]) * runner.removeFirst() * console.log(runner.tasks.pending) // [t2, t3, t4, t5, t6] * ``` */ removeFirst(): void; /** * Remove a pending task at a particular index. * * ```ts * runner.addMultiple([t1, t2, t3, t4, t5, t6]) * runner.removeAt(2) * console.log(runner.tasks.pending) // [t1, t2, t4, t5, t6] * ``` */ removeAt(index: number): void; /** * Remove a range of pending tasks. The range is inclusive of the starting index specified. * * ```ts * runner.addMultiple([t1, t2, t3, t4, t5, t6]) * runner.removeRange(2, 2) * console.log(runner.tasks.pending) // [t1, t4, t5, t6] * ``` */ removeRange(start: number, count: number): void; /** * Remove all pending tasks. * * ```ts * runner.addMultiple([t1, t2, t3, t4, t5, t6]) * runner.removeAll() * console.log(runner.tasks.pending) // [] * ``` */ removeAll(): void; /** * Add a listener to any of the supported events of the runner. Only one listener per event can be attached at any time. Adding another will overwrite the existing listener. */ addListener(event: `${E}`, listener: E extends RunnerEvents ? RunnerHooks[E] : never): void; /** * Remove a previously registered listener for an event supported by the runner. */ removeListener}`>(event: E): void; }