File tree 1 file changed +8
-2
lines changed
arduino-ide-extension/src/node/utils
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -3,15 +3,20 @@ export class SimpleBuffer {
3
3
4
4
private flushInterval ?: NodeJS . Timeout ;
5
5
6
+ private flush : ( ) => void ;
7
+
6
8
constructor ( onFlush : ( chunk : string ) => void , flushTimeout : number ) {
7
- this . flushInterval = setInterval ( ( ) => {
9
+ const flush = ( ) => {
8
10
if ( this . chunks . length > 0 ) {
9
11
const chunkString = Buffer . concat ( this . chunks ) . toString ( ) ;
10
12
this . clearChunks ( ) ;
11
13
12
14
onFlush ( chunkString ) ;
13
15
}
14
- } , flushTimeout ) ;
16
+ } ;
17
+
18
+ this . flush = flush ;
19
+ this . flushInterval = setInterval ( flush , flushTimeout ) ;
15
20
}
16
21
17
22
public addChunk ( chunk : Uint8Array ) : void {
@@ -23,6 +28,7 @@ export class SimpleBuffer {
23
28
}
24
29
25
30
public clearFlushInterval ( ) : void {
31
+ this . flush ( ) ;
26
32
this . clearChunks ( ) ;
27
33
28
34
clearInterval ( this . flushInterval ) ;
You can’t perform that action at this time.
0 commit comments