@@ -39,7 +39,6 @@ function isatty(fd) {
39
39
return Number . isInteger ( fd ) && fd >= 0 && isTTY ( fd ) ;
40
40
}
41
41
42
-
43
42
function ReadStream ( fd , options ) {
44
43
if ( ! ( this instanceof ReadStream ) )
45
44
return new ReadStream ( fd , options ) ;
@@ -66,7 +65,6 @@ ReadStream.prototype.setRawMode = function(flag) {
66
65
this . isRaw = flag ;
67
66
} ;
68
67
69
-
70
68
function WriteStream ( fd ) {
71
69
if ( ! ( this instanceof WriteStream ) )
72
70
return new WriteStream ( fd ) ;
@@ -86,16 +84,15 @@ function WriteStream(fd) {
86
84
// Ref: https://github.com/nodejs/node/pull/1771#issuecomment-119351671
87
85
this . _handle . setBlocking ( true ) ;
88
86
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 ) ;
91
89
if ( ! err ) {
92
90
this . columns = winSize [ 0 ] ;
93
91
this . rows = winSize [ 1 ] ;
94
92
}
95
93
}
96
94
inherits ( WriteStream , net . Socket ) ;
97
95
98
-
99
96
WriteStream . prototype . isTTY = true ;
100
97
101
98
WriteStream . prototype . getColorDepth = function ( env = process . env ) {
@@ -164,25 +161,23 @@ WriteStream.prototype.getColorDepth = function(env = process.env) {
164
161
} ;
165
162
166
163
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 ) ;
171
168
if ( err ) {
172
169
this . emit ( 'error' , errors . errnoException ( err , 'getWindowSize' ) ) ;
173
170
return ;
174
171
}
175
- var newCols = winSize [ 0 ] ;
176
- var newRows = winSize [ 1 ] ;
172
+ const [ newCols , newRows ] = winSize ;
177
173
if ( oldCols !== newCols || oldRows !== newRows ) {
178
174
this . columns = newCols ;
179
175
this . rows = newRows ;
180
176
this . emit ( 'resize' ) ;
181
177
}
182
178
} ;
183
179
184
-
185
- // backwards-compat
180
+ // Backwards-compat
186
181
WriteStream . prototype . cursorTo = function ( x , y ) {
187
182
readline . cursorTo ( this , x , y ) ;
188
183
} ;
@@ -199,5 +194,4 @@ WriteStream.prototype.getWindowSize = function() {
199
194
return [ this . columns , this . rows ] ;
200
195
} ;
201
196
202
-
203
197
module . exports = { isatty, ReadStream, WriteStream } ;
0 commit comments