You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: index.d.ts
+12Lines changed: 12 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,9 @@ export type LimitFunction = {
20
20
This might be useful if you want to teardown the queue at the end of your program's lifecycle or discard any function calls referencing an intermediary state of your app.
21
21
22
22
Note: This does not cancel promises that are already running.
23
+
24
+
When `rejectOnClear` is enabled, pending promises are rejected with an `AbortError`.
25
+
This is recommended if you await the returned promises, for example with `Promise.all`, so pending tasks do not remain unresolved after `clearQueue()`.
23
26
*/
24
27
clearQueue: ()=>void;
25
28
@@ -92,6 +95,15 @@ export type Options = {
92
95
Minimum: `1`.
93
96
*/
94
97
readonlyconcurrency: number;
98
+
99
+
/**
100
+
Reject pending promises with an `AbortError` when `clearQueue()` is called.
101
+
102
+
Default: `false`.
103
+
104
+
This is recommended if you await the returned promises, for example with `Promise.all`, so pending tasks do not remain unresolved after `clearQueue()`.
Copy file name to clipboardExpand all lines: readme.md
+20-1Lines changed: 20 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,15 @@ Minimum: `1`
41
41
42
42
Concurrency limit.
43
43
44
-
You can pass a number or an options object with a `concurrency` property:
44
+
You can pass a number or an options object with a `concurrency` property.
45
+
46
+
#### rejectOnClear
47
+
48
+
Type: `boolean`\
49
+
Default: `false`
50
+
51
+
Reject pending promises with an `AbortError` when `clearQueue()` is called.
52
+
This is recommended if you await the returned promises, for example with `Promise.all`, so pending tasks do not remain unresolved after `clearQueue()`.
45
53
46
54
```js
47
55
importpLimitfrom'p-limit';
@@ -93,6 +101,9 @@ This might be useful if you want to teardown the queue at the end of your progra
93
101
94
102
Note: This does not cancel promises that are already running.
95
103
104
+
When `rejectOnClear` is enabled, pending promises are rejected with an `AbortError`.
105
+
This is recommended if you await the returned promises, for example with `Promise.all`, so pending tasks do not remain unresolved after `clearQueue()`.
106
+
96
107
### limit.concurrency
97
108
98
109
Get or set the concurrency limit.
@@ -135,6 +146,14 @@ Minimum: `1`
135
146
136
147
Concurrency limit.
137
148
149
+
#### rejectOnClear
150
+
151
+
Type: `boolean`\
152
+
Default: `false`
153
+
154
+
Reject pending promises with an `AbortError` when `clearQueue()` is called.
155
+
This is recommended if you await the returned promises, for example with `Promise.all`, so pending tasks do not remain unresolved after `clearQueue()`.
156
+
138
157
## Recipes
139
158
140
159
See [recipes.md](recipes.md) for common use cases and patterns.
0 commit comments