UNPKG

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