Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4611381

Browse files
Akos Kittakittaakos
Akos Kitta
authored andcommitted
Merged in #1074.
Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent d6f4096 commit 4611381

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

‎arduino-ide-extension/src/node/utils/simple-buffer.ts‎

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,25 @@ import { OutputMessage } from '../../common/protocol';
44
const DEFAULT_FLUS_TIMEOUT_MS = 32;
55

66
export class SimpleBuffer implements Disposable {
7-
private readonly flush: () => void;
87
private readonly chunks = Chunks.create();
8+
private readonly flush: () => void;
99
private flushInterval?: NodeJS.Timeout;
1010

11-
constructor(onFlush: (chunk: string) => void, flushTimeout: number) {
12-
const flush = () => {
13-
if (this.chunks.length > 0) {
14-
const chunkString = Buffer.concat(this.chunks).toString();
11+
constructor(
12+
onFlush: (chunks: Map<OutputMessage.Severity, string | undefined>) => void,
13+
flushTimeout: number = DEFAULT_FLUS_TIMEOUT_MS
14+
) {
15+
this.flush = () => {
16+
if (!Chunks.isEmpty(this.chunks)) {
17+
const chunks = Chunks.toString(this.chunks);
1518
this.clearChunks();
1619
onFlush(chunks);
1720
}
1821
};
19-
20-
this.flush = flush;
21-
this.flushInterval = setInterval(flush, flushTimeout);
22+
this.flushInterval = setInterval(this.flush, flushTimeout);
2223
}
2324

24-
publicaddChunk(
25+
addChunk(
2526
chunk: Uint8Array,
2627
severity: OutputMessage.Severity = OutputMessage.Severity.Info
2728
): void {
@@ -32,10 +33,8 @@ export class SimpleBuffer implements Disposable {
3233
Chunks.clear(this.chunks);
3334
}
3435

35-
publicclearFlushInterval(): void {
36+
dispose(): void {
3637
this.flush();
37-
this.clearChunks();
38-
3938
clearInterval(this.flushInterval);
4039
this.clearChunks();
4140
this.flushInterval = undefined;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /