Musique/node_modules/m3u8stream/dist/queue.d.ts
2021-12-04 20:00:33 +01:00

39 lines
918 B
TypeScript

export declare type Callback = (err: Error | null, result?: any) => void;
interface Task<T> {
item: T;
callback?: Callback;
}
declare type Worker<T> = (item: T, cb: Callback) => void;
export declare class Queue<T = unknown> {
private _worker;
private _concurrency;
tasks: Task<T>[];
total: number;
active: number;
/**
* A really simple queue with concurrency.
*
* @param {Function} worker
* @param {Object} options
* @param {!number} options.concurrency
*/
constructor(worker: Worker<T>, options?: {
concurrency?: number;
});
/**
* Push a task to the queue.
*
* @param {T} item
* @param {!Function} callback
*/
push(item: T, callback?: Callback): void;
/**
* Process next job in queue.
*/
_next(): void;
/**
* Stops processing queued jobs.
*/
die(): void;
}
export {};