2121
2222'use strict' ;
2323
24- const util = require ( 'util' ) ;
24+ const { inherits , _errnoException , _extend } = require ( 'util' ) ;
2525const net = require ( 'net' ) ;
2626const { TTY , isTTY } = process . binding ( 'tty_wrap' ) ;
27- const { inherits } = util ;
28- const errnoException = util . _errnoException ;
2927const errors = require ( 'internal/errors' ) ;
3028const readline = require ( 'readline' ) ;
3129const { release } = require ( 'os' ) ;
@@ -41,7 +39,6 @@ function isatty(fd) {
4139 return Number . isInteger ( fd ) && fd >= 0 && isTTY ( fd ) ;
4240}
4341
44-
4542function ReadStream ( fd , options ) {
4643 if ( ! ( this instanceof ReadStream ) )
4744 return new ReadStream ( fd , options ) ;
@@ -54,7 +51,7 @@ function ReadStream(fd, options) {
5451 throw new errors . SystemError ( ctx ) ;
5552 }
5653
57- options = util . _extend ( {
54+ options = _extend ( {
5855 highWaterMark : 0 ,
5956 readable : true ,
6057 writable : false ,
@@ -74,7 +71,6 @@ ReadStream.prototype.setRawMode = function(flag) {
7471 this . isRaw = flag ;
7572} ;
7673
77-
7874function WriteStream ( fd ) {
7975 if ( ! ( this instanceof WriteStream ) )
8076 return new WriteStream ( fd ) ;
@@ -100,16 +96,15 @@ function WriteStream(fd) {
10096 // Ref: https://github.com/nodejs/node/pull/1771#issuecomment-119351671
10197 this . _handle . setBlocking ( true ) ;
10298
103- var winSize = new Array ( 2 ) ;
104- var err = this . _handle . getWindowSize ( winSize ) ;
99+ const winSize = new Array ( 2 ) ;
100+ const err = this . _handle . getWindowSize ( winSize ) ;
105101 if ( ! err ) {
106102 this . columns = winSize [ 0 ] ;
107103 this . rows = winSize [ 1 ] ;
108104 }
109105}
110106inherits ( WriteStream , net . Socket ) ;
111107
112-
113108WriteStream . prototype . isTTY = true ;
114109
115110WriteStream . prototype . getColorDepth = function ( env = process . env ) {
@@ -178,25 +173,23 @@ WriteStream.prototype.getColorDepth = function(env = process.env) {
178173} ;
179174
180175WriteStream . prototype . _refreshSize = function ( ) {
181- var oldCols = this . columns ;
182- var oldRows = this . rows ;
183- var winSize = new Array ( 2 ) ;
184- var err = this . _handle . getWindowSize ( winSize ) ;
176+ const oldCols = this . columns ;
177+ const oldRows = this . rows ;
178+ const winSize = new Array ( 2 ) ;
179+ const err = this . _handle . getWindowSize ( winSize ) ;
185180 if ( err ) {
186- this . emit ( 'error' , errnoException ( err , 'getWindowSize' ) ) ;
181+ this . emit ( 'error' , _errnoException ( err , 'getWindowSize' ) ) ;
187182 return ;
188183 }
189- var newCols = winSize [ 0 ] ;
190- var newRows = winSize [ 1 ] ;
184+ const [ newCols , newRows ] = winSize ;
191185 if ( oldCols !== newCols || oldRows !== newRows ) {
192186 this . columns = newCols ;
193187 this . rows = newRows ;
194188 this . emit ( 'resize' ) ;
195189 }
196190} ;
197191
198-
199- // backwards-compat
192+ // Backwards-compat
200193WriteStream . prototype . cursorTo = function ( x , y ) {
201194 readline . cursorTo ( this , x , y ) ;
202195} ;
@@ -213,5 +206,4 @@ WriteStream.prototype.getWindowSize = function() {
213206 return [ this . columns , this . rows ] ;
214207} ;
215208
216-
217209module . exports = { isatty, ReadStream, WriteStream } ;
0 commit comments