Skip to content

Commit 9318f82

Browse files
jasnelladdaleax
authored andcommitted
readline: use module.exports = {}
PR-URL: #12755 Reviewed-By: Anna Henningsen <[email protected]>
1 parent a398516 commit 9318f82

File tree

1 file changed

+19
-22
lines changed

1 file changed

+19
-22
lines changed

lib/readline.js

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const isFullWidthCodePoint = internalReadline.isFullWidthCodePoint;
4343
const stripVTControlCharacters = internalReadline.stripVTControlCharacters;
4444

4545

46-
exports.createInterface = function(input, output, completer, terminal) {
46+
function createInterface(input, output, completer, terminal) {
4747
return new Interface(input, output, completer, terminal);
4848
};
4949

@@ -311,13 +311,13 @@ Interface.prototype._refreshLine = function() {
311311
// first move to the bottom of the current line, based on cursor pos
312312
var prevRows = this.prevRows || 0;
313313
if (prevRows > 0) {
314-
exports.moveCursor(this.output, 0, -prevRows);
314+
moveCursor(this.output, 0, -prevRows);
315315
}
316316

317317
// Cursor to left edge.
318-
exports.cursorTo(this.output, 0);
318+
cursorTo(this.output, 0);
319319
// erase data
320-
exports.clearScreenDown(this.output);
320+
clearScreenDown(this.output);
321321

322322
// Write the prompt and the current buffer content.
323323
this._writeToOutput(line);
@@ -328,11 +328,11 @@ Interface.prototype._refreshLine = function() {
328328
}
329329

330330
// Move cursor to original position.
331-
exports.cursorTo(this.output, cursorPos.cols);
331+
cursorTo(this.output, cursorPos.cols);
332332

333333
var diff = lineRows - cursorPos.rows;
334334
if (diff > 0) {
335-
exports.moveCursor(this.output, 0, -diff);
335+
moveCursor(this.output, 0, -diff);
336336
}
337337

338338
this.prevRows = cursorPos.rows;
@@ -716,7 +716,7 @@ Interface.prototype._moveCursor = function(dx) {
716716
this.line.substring(this.cursor, oldcursor)
717717
);
718718
}
719-
exports.moveCursor(this.output, diffWidth, 0);
719+
moveCursor(this.output, diffWidth, 0);
720720
this.prevRows = newPos.rows;
721721
} else {
722722
this._refreshLine();
@@ -798,8 +798,8 @@ Interface.prototype._ttyWrite = function(s, key) {
798798
break;
799799

800800
case 'l': // clear the whole screen
801-
exports.cursorTo(this.output, 0, 0);
802-
exports.clearScreenDown(this.output);
801+
cursorTo(this.output, 0, 0);
802+
clearScreenDown(this.output);
803803
this._refreshLine();
804804
break;
805805

@@ -957,10 +957,6 @@ Interface.prototype._ttyWrite = function(s, key) {
957957
}
958958
};
959959

960-
961-
exports.Interface = Interface;
962-
963-
964960
/**
965961
* accepts a readable Stream instance and makes it emit "keypress" events
966962
*/
@@ -1036,8 +1032,6 @@ function emitKeypressEvents(stream, iface) {
10361032
stream.on('newListener', onNewListener);
10371033
}
10381034
}
1039-
exports.emitKeypressEvents = emitKeypressEvents;
1040-
10411035

10421036
/**
10431037
* moves the cursor to the x and y coordinate on the given stream
@@ -1059,8 +1053,6 @@ function cursorTo(stream, x, y) {
10591053
stream.write('\x1b[' + (y + 1) + ';' + (x + 1) + 'H');
10601054
}
10611055
}
1062-
exports.cursorTo = cursorTo;
1063-
10641056

10651057
/**
10661058
* moves the cursor relative to its current location
@@ -1082,8 +1074,6 @@ function moveCursor(stream, dx, dy) {
10821074
stream.write('\x1b[' + dy + 'B');
10831075
}
10841076
}
1085-
exports.moveCursor = moveCursor;
1086-
10871077

10881078
/**
10891079
* clears the current line the cursor is on:
@@ -1107,8 +1097,6 @@ function clearLine(stream, dir) {
11071097
stream.write('\x1b[2K');
11081098
}
11091099
}
1110-
exports.clearLine = clearLine;
1111-
11121100

11131101
/**
11141102
* clears the screen from the current position of the cursor down
@@ -1120,4 +1108,13 @@ function clearScreenDown(stream) {
11201108

11211109
stream.write('\x1b[0J');
11221110
}
1123-
exports.clearScreenDown = clearScreenDown;
1111+
1112+
module.exports = {
1113+
Interface,
1114+
clearLine,
1115+
clearScreenDown,
1116+
createInterface,
1117+
cursorTo,
1118+
emitKeypressEvents,
1119+
moveCursor
1120+
};

0 commit comments

Comments
 (0)