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>
This commit is contained in:
parent
d0bb9b1205
commit
2bfba0dd33
@ -26,9 +26,11 @@ const net = require('net');
|
|||||||
const { TTY, isTTY } = process.binding('tty_wrap');
|
const { TTY, isTTY } = process.binding('tty_wrap');
|
||||||
const errors = require('internal/errors');
|
const errors = require('internal/errors');
|
||||||
const { ERR_INVALID_FD, ERR_TTY_INIT_FAILED } = errors.codes;
|
const { ERR_INVALID_FD, ERR_TTY_INIT_FAILED } = errors.codes;
|
||||||
const readline = require('readline');
|
|
||||||
const { getColorDepth } = require('internal/tty');
|
const { getColorDepth } = require('internal/tty');
|
||||||
|
|
||||||
|
// Lazy loaded for startup performance.
|
||||||
|
let readline;
|
||||||
|
|
||||||
function isatty(fd) {
|
function isatty(fd) {
|
||||||
return Number.isInteger(fd) && fd >= 0 && isTTY(fd);
|
return Number.isInteger(fd) && fd >= 0 && isTTY(fd);
|
||||||
}
|
}
|
||||||
@ -122,15 +124,19 @@ WriteStream.prototype._refreshSize = function() {
|
|||||||
|
|
||||||
// Backwards-compat
|
// Backwards-compat
|
||||||
WriteStream.prototype.cursorTo = function(x, y) {
|
WriteStream.prototype.cursorTo = function(x, y) {
|
||||||
|
if (readline === undefined) readline = require('readline');
|
||||||
readline.cursorTo(this, x, y);
|
readline.cursorTo(this, x, y);
|
||||||
};
|
};
|
||||||
WriteStream.prototype.moveCursor = function(dx, dy) {
|
WriteStream.prototype.moveCursor = function(dx, dy) {
|
||||||
|
if (readline === undefined) readline = require('readline');
|
||||||
readline.moveCursor(this, dx, dy);
|
readline.moveCursor(this, dx, dy);
|
||||||
};
|
};
|
||||||
WriteStream.prototype.clearLine = function(dir) {
|
WriteStream.prototype.clearLine = function(dir) {
|
||||||
|
if (readline === undefined) readline = require('readline');
|
||||||
readline.clearLine(this, dir);
|
readline.clearLine(this, dir);
|
||||||
};
|
};
|
||||||
WriteStream.prototype.clearScreenDown = function() {
|
WriteStream.prototype.clearScreenDown = function() {
|
||||||
|
if (readline === undefined) readline = require('readline');
|
||||||
readline.clearScreenDown(this);
|
readline.clearScreenDown(this);
|
||||||
};
|
};
|
||||||
WriteStream.prototype.getWindowSize = function() {
|
WriteStream.prototype.getWindowSize = function() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user