code: function clearStringBackwards(stream: tty.WriteStream, str: string): void {
    readline.moveCursor(stream, -stream.columns, 0);
    readline.clearLine(stream, 0);
    let lineCount = (str.match(/\n/g) || []).length;
    while (lineCount > 0) {
      readline.moveCursor(stream, 0, -1);
      readline.clearLine(stream, 0);
      --lineCount;
    }
  }
docs: Clear some text that was previously printed on an interactive stream,
  without trailing newline character (so we have to move back to the
  beginning of the line).