diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2018-05-06 23:09:01 +0200 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2018-05-18 15:25:40 +0200 |
commit | 2bfba0dd339d1480e1b5caa64f28e330147845b9 (patch) | |
tree | 32539918cf608dffaef5ed5f4314bd927767d507 /lib/tty.js | |
parent | d0bb9b12051fa3540387a4c23d1f004b9d9a5a01 (diff) | |
download | android-node-v8-2bfba0dd339d1480e1b5caa64f28e330147845b9.tar.gz android-node-v8-2bfba0dd339d1480e1b5caa64f28e330147845b9.tar.bz2 android-node-v8-2bfba0dd339d1480e1b5caa64f28e330147845b9.zip |
readline: lazy loaded
PR-URL: https://github.com/nodejs/node/pull/20567
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Diffstat (limited to 'lib/tty.js')
-rw-r--r-- | lib/tty.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/tty.js b/lib/tty.js index 4e9023b0eb..b36adf2534 100644 --- a/lib/tty.js +++ b/lib/tty.js @@ -26,9 +26,11 @@ const net = require('net'); const { TTY, isTTY } = process.binding('tty_wrap'); const errors = require('internal/errors'); const { ERR_INVALID_FD, ERR_TTY_INIT_FAILED } = errors.codes; -const readline = require('readline'); const { getColorDepth } = require('internal/tty'); +// Lazy loaded for startup performance. +let readline; + function isatty(fd) { return Number.isInteger(fd) && fd >= 0 && isTTY(fd); } @@ -122,15 +124,19 @@ WriteStream.prototype._refreshSize = function() { // Backwards-compat WriteStream.prototype.cursorTo = function(x, y) { + if (readline === undefined) readline = require('readline'); readline.cursorTo(this, x, y); }; WriteStream.prototype.moveCursor = function(dx, dy) { + if (readline === undefined) readline = require('readline'); readline.moveCursor(this, dx, dy); }; WriteStream.prototype.clearLine = function(dir) { + if (readline === undefined) readline = require('readline'); readline.clearLine(this, dir); }; WriteStream.prototype.clearScreenDown = function() { + if (readline === undefined) readline = require('readline'); readline.clearScreenDown(this); }; WriteStream.prototype.getWindowSize = function() { |