Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3eb38de

Browse filesBrowse files
BridgeARMylesBorins
authored andcommitted
readline: lazy loaded
PR-URL: #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>
1 parent 4a92da1 commit 3eb38de
Copy full SHA for 3eb38de

File tree

Expand file treeCollapse file tree

1 file changed

+7
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-1
lines changed
Open diff view settings
Collapse file

‎lib/tty.js‎

Copy file name to clipboardExpand all lines: lib/tty.js
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ const net = require('net');
2626
const { TTY, isTTY } = process.binding('tty_wrap');
2727
const errors = require('internal/errors');
2828
const { ERR_INVALID_FD, ERR_TTY_INIT_FAILED } = errors.codes;
29-
const readline = require('readline');
3029
const { getColorDepth } = require('internal/tty');
3130

31+
// Lazy loaded for startup performance.
32+
let readline;
33+
3234
function isatty(fd) {
3335
return Number.isInteger(fd) && fd >= 0 && isTTY(fd);
3436
}
@@ -122,15 +124,19 @@ WriteStream.prototype._refreshSize = function() {
122124

123125
// Backwards-compat
124126
WriteStream.prototype.cursorTo = function(x, y) {
127+
if (readline === undefined) readline = require('readline');
125128
readline.cursorTo(this, x, y);
126129
};
127130
WriteStream.prototype.moveCursor = function(dx, dy) {
131+
if (readline === undefined) readline = require('readline');
128132
readline.moveCursor(this, dx, dy);
129133
};
130134
WriteStream.prototype.clearLine = function(dir) {
135+
if (readline === undefined) readline = require('readline');
131136
readline.clearLine(this, dir);
132137
};
133138
WriteStream.prototype.clearScreenDown = function() {
139+
if (readline === undefined) readline = require('readline');
134140
readline.clearScreenDown(this);
135141
};
136142
WriteStream.prototype.getWindowSize = function() {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.