UNPKG

@buttercup/channel-queue

Version:

A queue management library with channels

65 lines (64 loc) 1.51 kB
import { Callable, TaskPriority } from "./types"; /** * Internal Task class, for handling executions */ export declare class Task { private _created; private _error; private _queuedPromise; private _rejectFn; private _resolveFn; private _stack; private _target; private _timeLimit; private _type; /** * Constructor for a Task * @param {Function|Promise} item The item to enqueue * @param {TaskPriority=} type The priority to set * @param {String=} stack The stack name */ constructor(item: Callable<any>, type?: TaskPriority, stack?: string | null); /** * Creation timestamp * @type {Number} * @readonly */ get created(): number; /** * Execution error, if one occurred * @type {Error | null} */ get error(): Error | null; /** * Promise which resolves when work has completed * @type {Promise} */ get queuedPromise(): Promise<any>; /** * The stack name * @type {String} */ get stack(): string; /** * The target function * @type {Function} */ get target(): Callable<any>; /** * Current time limit * @type {Number} */ get timeLimit(): number; /** * The task priority type * @type {TaskPriority} */ get type(): TaskPriority; set timeLimit(newLimit: number); /** * Execute the task * @returns {Promise} */ execute(throws?: boolean): Promise<void>; }