options.d.ts 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { Queue, RunFunction } from './queue';
  2. export interface QueueAddOptions {
  3. readonly [key: string]: unknown;
  4. }
  5. export interface Options<QueueType extends Queue<RunFunction, QueueOptions>, QueueOptions extends QueueAddOptions> {
  6. /**
  7. Concurrency limit.
  8. Minimum: `1`.
  9. @default Infinity
  10. */
  11. readonly concurrency?: number;
  12. /**
  13. Whether queue tasks within concurrency limit, are auto-executed as soon as they're added.
  14. @default true
  15. */
  16. readonly autoStart?: boolean;
  17. /**
  18. Class with a `enqueue` and `dequeue` method, and a `size` getter. See the [Custom QueueClass](https://github.com/sindresorhus/p-queue#custom-queueclass) section.
  19. */
  20. readonly queueClass?: new () => QueueType;
  21. /**
  22. The max number of runs in the given interval of time.
  23. Minimum: `1`.
  24. @default Infinity
  25. */
  26. readonly intervalCap?: number;
  27. /**
  28. The length of time in milliseconds before the interval count resets. Must be finite.
  29. Minimum: `0`.
  30. @default 0
  31. */
  32. readonly interval?: number;
  33. /**
  34. Whether the task must finish in the given interval or will be carried over into the next interval count.
  35. @default false
  36. */
  37. readonly carryoverConcurrencyCount?: boolean;
  38. /**
  39. Per-operation timeout in milliseconds. Operations fulfill once `timeout` elapses if they haven't already.
  40. */
  41. timeout?: number;
  42. /**
  43. Whether or not a timeout is considered an exception.
  44. @default false
  45. */
  46. throwOnTimeout?: boolean;
  47. }
  48. export interface DefaultAddOptions extends QueueAddOptions {
  49. /**
  50. Priority of operation. Operations with greater priority will be scheduled first.
  51. @default 0
  52. */
  53. readonly priority?: number;
  54. }