UNPKG

700 BTypeScriptView Raw
1declare type Callback = (err?: Error, result?: any) => void;
2interface Task {
3 item: {};
4 callback: Callback;
5}
6export default class Queue {
7 _worker: (item: any, cb: Callback) => void;
8 _concurrency: number;
9 tasks: Task[];
10 total: number;
11 active: number;
12 /**
13 * A really simple queue with concurrency.
14 */
15 constructor(worker: (item: any, cb: Callback) => void, options?: {
16 concurrency?: number;
17 });
18 /**
19 * Push a task to the queue.
20 */
21 push(item: any, callback?: Callback): void;
22 /**
23 * Process next job in queue.
24 */
25 _next(): void;
26 /**
27 * Stops processing queued jobs.
28 */
29 die(): void;
30}
31export {};