aboutsummaryrefslogtreecommitdiff
path: root/editors/code/src/commands/line_buffer.ts
diff options
context:
space:
mode:
authorEdwin Cheng <[email protected]>2019-04-02 07:43:02 +0100
committerEdwin Cheng <[email protected]>2019-04-02 08:03:31 +0100
commit02e450f354ccd978c90425929c635139210843a3 (patch)
tree008e2bc12c024b480d86a4dae7194b976cad494d /editors/code/src/commands/line_buffer.ts
parentee05eafe6c657c3d3710655e11d88d61bc5febf0 (diff)
Add cargo-watch.check-arguments
Diffstat (limited to 'editors/code/src/commands/line_buffer.ts')
-rw-r--r--editors/code/src/commands/line_buffer.ts16
1 files changed, 16 insertions, 0 deletions
diff --git a/editors/code/src/commands/line_buffer.ts b/editors/code/src/commands/line_buffer.ts
new file mode 100644
index 000000000..fb5b9f7f2
--- /dev/null
+++ b/editors/code/src/commands/line_buffer.ts
@@ -0,0 +1,16 @@
1export class LineBuffer {
2 private outBuffer: string = '';
3
4 public processOutput(chunk: string, cb: (line: string) => void) {
5 this.outBuffer += chunk;
6 let eolIndex = this.outBuffer.indexOf('\n');
7 while (eolIndex >= 0) {
8 // line includes the EOL
9 const line = this.outBuffer.slice(0, eolIndex + 1);
10 cb(line);
11 this.outBuffer = this.outBuffer.slice(eolIndex + 1);
12
13 eolIndex = this.outBuffer.indexOf('\n');
14 }
15 }
16}