Skip to content

Commit dc88b65

Browse files
JacksonTianMylesBorins
authored andcommitted
readline: refactor construct Interface
Remove the dependency on the arguments.length. PR-URL: #4740 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Trevor Norris <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent 93877c8 commit dc88b65

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

lib/readline.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,13 @@ const stripVTControlCharacters = internalReadline.stripVTControlCharacters;
2424

2525

2626
exports.createInterface = function(input, output, completer, terminal) {
27-
var rl;
28-
if (arguments.length === 1) {
29-
rl = new Interface(input);
30-
} else {
31-
rl = new Interface(input, output, completer, terminal);
32-
}
33-
return rl;
27+
return new Interface(input, output, completer, terminal);
3428
};
3529

3630

3731
function Interface(input, output, completer, terminal) {
3832
if (!(this instanceof Interface)) {
39-
// call the constructor preserving original number of arguments
40-
const self = Object.create(Interface.prototype);
41-
Interface.apply(self, arguments);
42-
return self;
33+
return new Interface(input, output, completer, terminal);
4334
}
4435

4536
this._sawReturnAt = 0;
@@ -51,7 +42,7 @@ function Interface(input, output, completer, terminal) {
5142
let crlfDelay;
5243
let prompt = '> ';
5344

54-
if (arguments.length === 1) {
45+
if (input && input.input) {
5546
// an options object was given
5647
output = input.output;
5748
completer = input.completer;

0 commit comments

Comments
 (0)