GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — tty: refactor to es6 · nodejs/node@74f0d1a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • tty.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎lib/tty.js‎

Copy file name to clipboardExpand all lines: lib/tty.js
+8-14Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ function isatty(fd) {
3939
return Number.isInteger(fd) && fd >= 0 && isTTY(fd);
4040
}
4141

42-
4342
function ReadStream(fd, options) {
4443
if (!(this instanceof ReadStream))
4544
return new ReadStream(fd, options);
@@ -66,7 +65,6 @@ ReadStream.prototype.setRawMode = function(flag) {
6665
this.isRaw = flag;
6766
};
6867

69-
7068
function WriteStream(fd) {
7169
if (!(this instanceof WriteStream))
7270
return new WriteStream(fd);
@@ -86,16 +84,15 @@ function WriteStream(fd) {
8684
// Ref: https://github.com/nodejs/node/pull/1771#issuecomment-119351671
8785
this._handle.setBlocking(true);
8886

89-
var winSize = new Array(2);
90-
var err = this._handle.getWindowSize(winSize);
87+
const winSize = new Array(2);
88+
const err = this._handle.getWindowSize(winSize);
9189
if (!err) {
9290
this.columns = winSize[0];
9391
this.rows = winSize[1];
9492
}
9593
}
9694
inherits(WriteStream, net.Socket);
9795

98-
9996
WriteStream.prototype.isTTY = true;
10097

10198
WriteStream.prototype.getColorDepth = function(env = process.env) {
@@ -164,25 +161,23 @@ WriteStream.prototype.getColorDepth = function(env = process.env) {
164161
};
165162

166163
WriteStream.prototype._refreshSize = function() {
167-
var oldCols = this.columns;
168-
var oldRows = this.rows;
169-
var winSize = new Array(2);
170-
var err = this._handle.getWindowSize(winSize);
164+
const oldCols = this.columns;
165+
const oldRows = this.rows;
166+
const winSize = new Array(2);
167+
const err = this._handle.getWindowSize(winSize);
171168
if (err) {
172169
this.emit('error', errors.errnoException(err, 'getWindowSize'));
173170
return;
174171
}
175-
var newCols = winSize[0];
176-
var newRows = winSize[1];
172+
const [newCols, newRows] = winSize;
177173
if (oldCols !== newCols || oldRows !== newRows) {
178174
this.columns = newCols;
179175
this.rows = newRows;
180176
this.emit('resize');
181177
}
182178
};
183179

184-
185-
// backwards-compat
180+
// Backwards-compat
186181
WriteStream.prototype.cursorTo = function(x, y) {
187182
readline.cursorTo(this, x, y);
188183
};
@@ -199,5 +194,4 @@ WriteStream.prototype.getWindowSize = function() {
199194
return [this.columns, this.rows];
200195
};
201196

202-
203197
module.exports = { isatty, ReadStream, WriteStream };

0 commit comments

Comments
0 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.