File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 1
- export class PQueue < T > {
2
- private heap : { value : T ; priority : number } [ ] = [ ] ;
1
+ export class PQueue < T > implements AsyncIterable < T > , Disposable {
3
2
private closed = false ;
4
- private pendingShifts : ( ( value : IteratorResult < T > ) => void ) [ ] = [ ] ;
5
- private pendingRejects : ( ( reason ?: any ) => void ) [ ] = [ ] ;
3
+ private readonly heap : { value : T ; priority : number } [ ] = [ ] ;
4
+ private readonly pendingShifts : ( ( value : IteratorResult < T > ) => void ) [ ] = [ ] ;
5
+ private readonly pendingRejects : ( ( reason ?: any ) => void ) [ ] = [ ] ;
6
6
7
7
get size ( ) : number {
8
8
return this . heap . length ;
@@ -96,4 +96,11 @@ export class PQueue<T> {
96
96
yield value ;
97
97
}
98
98
}
99
+
100
+ [ Symbol . dispose ] ( ) {
101
+ this . close ( ) ;
102
+ this . heap . length = 0 ;
103
+ this . pendingShifts . length = 0 ;
104
+ this . pendingRejects . length = 0 ;
105
+ }
99
106
}
You can’t perform that action at this time.
0 commit comments