You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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