All files / tap-bark/src/stream stream.ts

100% Statements 21/21
100% Branches 0/0
100% Functions 9/9
100% Lines 20/20
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42  1x 1x   1x   40x   1x 30x       18x     1x 15x     1x 299x     1x 601x     1x 305x     1x 299x     1x 7x     1x  
import { IStream } from "./stream.i";
import * as readline from "readline";
const through = require("through2");
 
export class Stream implements IStream {
 
   private _stream: NodeJS.WritableStream = through();
 
   public get stream() {
      return this._stream;
   }
 
   public set stream (value) {
      this._stream = value;
   }
 
    public writeLine(message: string): void {
        this._stream.write(message + "\n");
    }
 
    public write(message: string): void {
        this._stream.write(message);
    }
 
    public moveCursor(x: number, y: number): void {
        readline.moveCursor(this._stream, x, y);
    }
 
    public cursorTo(x: number, y: number): void {
        readline.cursorTo(this._stream, x, y);
    }
 
    public clearLine(): void {
        readline.clearLine(this._stream, 0);
    }
 
    public getUnderlyingStream(): NodeJS.WritableStream {
        return this._stream;
    }
 
}