File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
arduino-ide-extension/src/node/utils Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -3,15 +3,20 @@ export class SimpleBuffer {
33
44 private flushInterval ?: NodeJS . Timeout ;
55
6+ private flush : ( ) => void ;
7+
68 constructor ( onFlush : ( chunk : string ) => void , flushTimeout : number ) {
7- this . flushInterval = setInterval ( ( ) => {
9+ const flush = ( ) => {
810 if ( this . chunks . length > 0 ) {
911 const chunkString = Buffer . concat ( this . chunks ) . toString ( ) ;
1012 this . clearChunks ( ) ;
1113
1214 onFlush ( chunkString ) ;
1315 }
14- } , flushTimeout ) ;
16+ } ;
17+
18+ this . flush = flush ;
19+ this . flushInterval = setInterval ( flush , flushTimeout ) ;
1520 }
1621
1722 public addChunk ( chunk : Uint8Array ) : void {
@@ -23,6 +28,7 @@ export class SimpleBuffer {
2328 }
2429
2530 public clearFlushInterval ( ) : void {
31+ this . flush ( ) ;
2632 this . clearChunks ( ) ;
2733
2834 clearInterval ( this . flushInterval ) ;
You can’t perform that action at this time.
0 commit comments