@@ -26,9 +26,11 @@ const net = require('net');
26
26
const { TTY , isTTY } = process . binding ( 'tty_wrap' ) ;
27
27
const errors = require ( 'internal/errors' ) ;
28
28
const { ERR_INVALID_FD , ERR_TTY_INIT_FAILED } = errors . codes ;
29
- const readline = require ( 'readline' ) ;
30
29
const { getColorDepth } = require ( 'internal/tty' ) ;
31
30
31
+ // Lazy loaded for startup performance.
32
+ let readline ;
33
+
32
34
function isatty ( fd ) {
33
35
return Number . isInteger ( fd ) && fd >= 0 && isTTY ( fd ) ;
34
36
}
@@ -122,15 +124,19 @@ WriteStream.prototype._refreshSize = function() {
122
124
123
125
// Backwards-compat
124
126
WriteStream . prototype . cursorTo = function ( x , y ) {
127
+ if ( readline === undefined ) readline = require ( 'readline' ) ;
125
128
readline . cursorTo ( this , x , y ) ;
126
129
} ;
127
130
WriteStream . prototype . moveCursor = function ( dx , dy ) {
131
+ if ( readline === undefined ) readline = require ( 'readline' ) ;
128
132
readline . moveCursor ( this , dx , dy ) ;
129
133
} ;
130
134
WriteStream . prototype . clearLine = function ( dir ) {
135
+ if ( readline === undefined ) readline = require ( 'readline' ) ;
131
136
readline . clearLine ( this , dir ) ;
132
137
} ;
133
138
WriteStream . prototype . clearScreenDown = function ( ) {
139
+ if ( readline === undefined ) readline = require ( 'readline' ) ;
134
140
readline . clearScreenDown ( this ) ;
135
141
} ;
136
142
WriteStream . prototype . getWindowSize = function ( ) {
0 commit comments