1 | declare function fastq<C, T = any, R = any>(context: C, worker: fastq.worker<C, T, R>, concurrency: number): fastq.queue<T, R>
|
---|
2 | declare function fastq<C, T = any, R = any>(worker: fastq.worker<C, T, R>, concurrency: number): fastq.queue<T, R>
|
---|
3 |
|
---|
4 | declare namespace fastq {
|
---|
5 | type worker<C, T = any, R = any> = (this: C, task: T, cb: fastq.done<R>) => void
|
---|
6 | type asyncWorker<C, T = any, R = any> = (this: C, task: T) => Promise<R>
|
---|
7 | type done<R = any> = (err: Error | null, result?: R) => void
|
---|
8 | type errorHandler<T = any> = (err: Error, task: T) => void
|
---|
9 |
|
---|
10 | interface queue<T = any, R = any> {
|
---|
11 | push(task: T, done?: done<R>): void
|
---|
12 | unshift(task: T, done?: done<R>): void
|
---|
13 | pause(): any
|
---|
14 | resume(): any
|
---|
15 | running(): number
|
---|
16 | idle(): boolean
|
---|
17 | length(): number
|
---|
18 | getQueue(): T[]
|
---|
19 | kill(): any
|
---|
20 | killAndDrain(): any
|
---|
21 | error(handler: errorHandler<T>): void
|
---|
22 | concurrency: number
|
---|
23 | drain(): any
|
---|
24 | empty: () => void
|
---|
25 | saturated: () => void
|
---|
26 | }
|
---|
27 |
|
---|
28 | interface queueAsPromised<T = any, R = any> extends queue<T, R> {
|
---|
29 | push(task: T): Promise<R>
|
---|
30 | unshift(task: T): Promise<R>
|
---|
31 | drained(): Promise<void>
|
---|
32 | }
|
---|
33 |
|
---|
34 | function promise<C, T = any, R = any>(context: C, worker: fastq.asyncWorker<C, T, R>, concurrency: number): fastq.queueAsPromised<T, R>
|
---|
35 | function promise<C, T = any, R = any>(worker: fastq.asyncWorker<C, T, R>, concurrency: number): fastq.queueAsPromised<T, R>
|
---|
36 | }
|
---|
37 |
|
---|
38 | export = fastq
|
---|