@@ -416,18 +416,24 @@ export abstract class AsyncReadonlyQueue<T> {
416
416
} ) ;
417
417
}
418
418
419
- conflate < U > ( reducer : ( prior : T , next : T ) => Promise < T > | T ) : AsyncReadonlyQueue < T > {
419
+ conflate < U > ( reducer : ( prior : T , next : T , signal : AbortSignal ) => Promise < T > | T ) : AsyncReadonlyQueue < T > {
420
420
let accumulator : T | undefined = undefined ;
421
421
422
- const conflatedQueue = new AsyncKeepLastQueue < T > ( "conflate" , this . _maxBufferSize ) ;
422
+ const abortController = new AbortController ( ) ;
423
+ const conflatedQueue = new AsyncKeepLastQueue < T > (
424
+ "conflate" ,
425
+ this . _maxBufferSize ,
426
+ ( ) => abortController . abort ( ) ,
427
+ [ this ] ,
428
+ ) ;
423
429
424
430
( async ( ) => {
425
431
for await ( const item of this . items ( ) ) {
426
432
if ( conflatedQueue . isCompleted ) return ;
427
433
if ( accumulator === undefined ) {
428
434
accumulator = item ;
429
435
} else {
430
- accumulator = await reducer ( accumulator , item ) ;
436
+ accumulator = await reducer ( accumulator , item , abortController . signal ) ;
431
437
}
432
438
433
439
conflatedQueue . accumulate ( accumulator ) ;
@@ -451,6 +457,7 @@ export abstract class AsyncReadonlyQueue<T> {
451
457
"conflateWithSeed" ,
452
458
this . _maxBufferSize ,
453
459
( ) => abortController . abort ( ) ,
460
+ [ this ] ,
454
461
) ;
455
462
456
463
( async ( ) => {
@@ -487,7 +494,7 @@ export abstract class AsyncReadonlyQueue<T> {
487
494
"conflateWithSeedFn" ,
488
495
this . _maxBufferSize ,
489
496
( ) => abortController . abort ( ) ,
490
- undefined ,
497
+ [ this ] ,
491
498
( ) => {
492
499
accumulator = undefined ;
493
500
} ,
@@ -527,7 +534,12 @@ export abstract class AsyncReadonlyQueue<T> {
527
534
let lastItem : T | undefined = undefined ;
528
535
let timer : number | undefined = undefined ;
529
536
530
- const debouncedQueue = new AsyncKeepLastQueue < T > ( "debounce" , this . _maxBufferSize ) ;
537
+ const debouncedQueue = new AsyncKeepLastQueue < T > (
538
+ "debounce" ,
539
+ this . _maxBufferSize ,
540
+ undefined ,
541
+ [ this ] ,
542
+ ) ;
531
543
532
544
( async ( ) => {
533
545
for await ( const item of this . items ( ) ) {
0 commit comments