diff --git a/lib/tty.js b/lib/tty.js index 8b6ce251c7c3ff..12d0836cde5db5 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -39,7 +39,6 @@ function isatty(fd) { return Number.isInteger(fd) && fd >= 0 && isTTY(fd); } - function ReadStream(fd, options) { if (!(this instanceof ReadStream)) return new ReadStream(fd, options); @@ -66,7 +65,6 @@ ReadStream.prototype.setRawMode = function(flag) { this.isRaw = flag; }; - function WriteStream(fd) { if (!(this instanceof WriteStream)) return new WriteStream(fd); @@ -86,8 +84,8 @@ function WriteStream(fd) { // Ref: https://github.com/nodejs/node/pull/1771#issuecomment-119351671 this._handle.setBlocking(true); - var winSize = new Array(2); - var err = this._handle.getWindowSize(winSize); + const winSize = new Array(2); + const err = this._handle.getWindowSize(winSize); if (!err) { this.columns = winSize[0]; this.rows = winSize[1]; @@ -95,7 +93,6 @@ function WriteStream(fd) { } inherits(WriteStream, net.Socket); - WriteStream.prototype.isTTY = true; WriteStream.prototype.getColorDepth = function(env = process.env) { @@ -164,16 +161,15 @@ WriteStream.prototype.getColorDepth = function(env = process.env) { }; WriteStream.prototype._refreshSize = function() { - var oldCols = this.columns; - var oldRows = this.rows; - var winSize = new Array(2); - var err = this._handle.getWindowSize(winSize); + const oldCols = this.columns; + const oldRows = this.rows; + const winSize = new Array(2); + const err = this._handle.getWindowSize(winSize); if (err) { this.emit('error', errors.errnoException(err, 'getWindowSize')); return; } - var newCols = winSize[0]; - var newRows = winSize[1]; + const [newCols, newRows] = winSize; if (oldCols !== newCols || oldRows !== newRows) { this.columns = newCols; this.rows = newRows; @@ -181,8 +177,7 @@ WriteStream.prototype._refreshSize = function() { } }; - -// backwards-compat +// Backwards-compat WriteStream.prototype.cursorTo = function(x, y) { readline.cursorTo(this, x, y); }; @@ -199,5 +194,4 @@ WriteStream.prototype.getWindowSize = function() { return [this.columns, this.rows]; }; - module.exports = { isatty, ReadStream, WriteStream };