@@ -26,9 +26,11 @@ const net = require('net');
2626const { TTY , isTTY } = process . binding ( 'tty_wrap' ) ;
2727const errors = require ( 'internal/errors' ) ;
2828const { ERR_INVALID_FD , ERR_TTY_INIT_FAILED } = errors . codes ;
29- const readline = require ( 'readline' ) ;
3029const { getColorDepth } = require ( 'internal/tty' ) ;
3130
31+ // Lazy loaded for startup performance.
32+ let readline ;
33+
3234function isatty ( fd ) {
3335 return Number . isInteger ( fd ) && fd >= 0 && isTTY ( fd ) ;
3436}
@@ -122,15 +124,19 @@ WriteStream.prototype._refreshSize = function() {
122124
123125// Backwards-compat
124126WriteStream . prototype . cursorTo = function ( x , y ) {
127+ if ( readline === undefined ) readline = require ( 'readline' ) ;
125128 readline . cursorTo ( this , x , y ) ;
126129} ;
127130WriteStream . prototype . moveCursor = function ( dx , dy ) {
131+ if ( readline === undefined ) readline = require ( 'readline' ) ;
128132 readline . moveCursor ( this , dx , dy ) ;
129133} ;
130134WriteStream . prototype . clearLine = function ( dir ) {
135+ if ( readline === undefined ) readline = require ( 'readline' ) ;
131136 readline . clearLine ( this , dir ) ;
132137} ;
133138WriteStream . prototype . clearScreenDown = function ( ) {
139+ if ( readline === undefined ) readline = require ( 'readline' ) ;
134140 readline . clearScreenDown ( this ) ;
135141} ;
136142WriteStream . prototype . getWindowSize = function ( ) {
0 commit comments