UNPKG

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