@@ -42,6 +42,12 @@ function isPromiseWithCancel<T>(value: unknown): value is PromiseWithCancel<T> {
42
42
* [real-cancellable-promise](https://github.com/srmagura/real-cancellable-promise).
43
43
*
44
44
* @typeParam T what the `CancellablePromise` resolves to
45
+ *
46
+ * @groupDescription Methods
47
+ * Descriptions can be added for groups with `@groupDescription`, which will show up in
48
+ * the index where groups are listed. This works for both manually created groups which
49
+ * are created with `@group`, and implicit groups like the `Methods` group that this
50
+ * description is attached to.
45
51
*/
46
52
export class CancellablePromise < T > {
47
53
/**
@@ -100,7 +106,7 @@ export class CancellablePromise<T> {
100
106
onRejected ?:
101
107
| ( ( reason : any ) => TResult2 | PromiseLike < TResult2 > )
102
108
| undefined
103
- | null
109
+ | null ,
104
110
) : CancellablePromise < TResult1 | TResult2 > {
105
111
let fulfill ;
106
112
let reject ;
@@ -147,7 +153,7 @@ export class CancellablePromise<T> {
147
153
onRejected ?:
148
154
| ( ( reason : any ) => TResult | PromiseLike < TResult > )
149
155
| undefined
150
- | null
156
+ | null ,
151
157
) : CancellablePromise < T | TResult > {
152
158
return this . then ( undefined , onRejected ) ;
153
159
}
@@ -161,11 +167,11 @@ export class CancellablePromise<T> {
161
167
* @returns A Promise for the completion of the callback.
162
168
*/
163
169
finally (
164
- onFinally ?: ( ( ) => void ) | undefined | null
170
+ onFinally ?: ( ( ) => void ) | undefined | null ,
165
171
) : CancellablePromise < T > {
166
172
return new CancellablePromise (
167
173
this . promise . finally ( onFinally ) ,
168
- this . cancel
174
+ this . cancel ,
169
175
) ;
170
176
}
171
177
@@ -207,8 +213,8 @@ export class CancellablePromise<T> {
207
213
T7 | PromiseLike < T7 > ,
208
214
T8 | PromiseLike < T8 > ,
209
215
T9 | PromiseLike < T9 > ,
210
- T10 | PromiseLike < T10 >
211
- ]
216
+ T10 | PromiseLike < T10 > ,
217
+ ] ,
212
218
) : CancellablePromise < [ T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 , T10 ] > ;
213
219
214
220
static all < T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 > (
@@ -221,8 +227,8 @@ export class CancellablePromise<T> {
221
227
T6 | PromiseLike < T6 > ,
222
228
T7 | PromiseLike < T7 > ,
223
229
T8 | PromiseLike < T8 > ,
224
- T9 | PromiseLike < T9 >
225
- ]
230
+ T9 | PromiseLike < T9 > ,
231
+ ] ,
226
232
) : CancellablePromise < [ T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 , T9 ] > ;
227
233
228
234
static all < T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 > (
@@ -234,8 +240,8 @@ export class CancellablePromise<T> {
234
240
T5 | PromiseLike < T5 > ,
235
241
T6 | PromiseLike < T6 > ,
236
242
T7 | PromiseLike < T7 > ,
237
- T8 | PromiseLike < T8 >
238
- ]
243
+ T8 | PromiseLike < T8 > ,
244
+ ] ,
239
245
) : CancellablePromise < [ T1 , T2 , T3 , T4 , T5 , T6 , T7 , T8 ] > ;
240
246
241
247
static all < T1 , T2 , T3 , T4 , T5 , T6 , T7 > (
@@ -246,8 +252,8 @@ export class CancellablePromise<T> {
246
252
T4 | PromiseLike < T4 > ,
247
253
T5 | PromiseLike < T5 > ,
248
254
T6 | PromiseLike < T6 > ,
249
- T7 | PromiseLike < T7 >
250
- ]
255
+ T7 | PromiseLike < T7 > ,
256
+ ] ,
251
257
) : CancellablePromise < [ T1 , T2 , T3 , T4 , T5 , T6 , T7 ] > ;
252
258
253
259
static all < T1 , T2 , T3 , T4 , T5 , T6 > (
@@ -257,8 +263,8 @@ export class CancellablePromise<T> {
257
263
T3 | PromiseLike < T3 > ,
258
264
T4 | PromiseLike < T4 > ,
259
265
T5 | PromiseLike < T5 > ,
260
- T6 | PromiseLike < T6 >
261
- ]
266
+ T6 | PromiseLike < T6 > ,
267
+ ] ,
262
268
) : CancellablePromise < [ T1 , T2 , T3 , T4 , T5 , T6 ] > ;
263
269
264
270
static all < T1 , T2 , T3 , T4 , T5 > (
@@ -267,33 +273,33 @@ export class CancellablePromise<T> {
267
273
T2 | PromiseLike < T2 > ,
268
274
T3 | PromiseLike < T3 > ,
269
275
T4 | PromiseLike < T4 > ,
270
- T5 | PromiseLike < T5 >
271
- ]
276
+ T5 | PromiseLike < T5 > ,
277
+ ] ,
272
278
) : CancellablePromise < [ T1 , T2 , T3 , T4 , T5 ] > ;
273
279
274
280
static all < T1 , T2 , T3 , T4 > (
275
281
values : readonly [
276
282
T1 | PromiseLike < T1 > ,
277
283
T2 | PromiseLike < T2 > ,
278
284
T3 | PromiseLike < T3 > ,
279
- T4 | PromiseLike < T4 >
280
- ]
285
+ T4 | PromiseLike < T4 > ,
286
+ ] ,
281
287
) : CancellablePromise < [ T1 , T2 , T3 , T4 ] > ;
282
288
283
289
static all < T1 , T2 , T3 > (
284
290
values : readonly [
285
291
T1 | PromiseLike < T1 > ,
286
292
T2 | PromiseLike < T2 > ,
287
- T3 | PromiseLike < T3 >
288
- ]
293
+ T3 | PromiseLike < T3 > ,
294
+ ] ,
289
295
) : CancellablePromise < [ T1 , T2 , T3 ] > ;
290
296
291
297
static all < T1 , T2 > (
292
- values : readonly [ T1 | PromiseLike < T1 > , T2 | PromiseLike < T2 > ]
298
+ values : readonly [ T1 | PromiseLike < T1 > , T2 | PromiseLike < T2 > ] ,
293
299
) : CancellablePromise < [ T1 , T2 ] > ;
294
300
295
301
static all < T > (
296
- values : readonly ( T | PromiseLike < T > ) [ ]
302
+ values : readonly ( T | PromiseLike < T > ) [ ] ,
297
303
) : CancellablePromise < T [ ] > ;
298
304
299
305
/**
@@ -319,7 +325,7 @@ export class CancellablePromise<T> {
319
325
* @returns A new `CancellablePromise`.
320
326
*/
321
327
static allSettled < T extends readonly unknown [ ] | readonly [ unknown ] > (
322
- values : T
328
+ values : T ,
323
329
) : CancellablePromise < {
324
330
- readonly [ P in keyof T ] : PromiseSettledResult <
325
331
T [ P ] extends PromiseLike < infer U > ? U : T [ P ]
@@ -335,7 +341,7 @@ export class CancellablePromise<T> {
335
341
* promises.
336
342
*/
337
343
static allSettled < T > (
338
- values : Iterable < T >
344
+ values : Iterable < T > ,
339
345
) : CancellablePromise <
340
346
PromiseSettledResult < T extends PromiseLike < infer U > ? U : T > [ ]
341
347
> ;
@@ -375,7 +381,7 @@ export class CancellablePromise<T> {
375
381
* @returns a `CancellablePromise` that resolves after `ms` milliseconds.
376
382
*/
377
383
static delay ( ms : number ) : CancellablePromise < void > {
378
- let timer : NodeJS . Timer | undefined ;
384
+ let timer : ReturnType < typeof setTimeout > | undefined ;
379
385
let rejectFn : ( reason ?: any ) => void = noop ;
380
386
381
387
const promise = new Promise < void > ( ( resolve , reject ) => {
0 commit comments