Skip to content

Commit c4a12c8

Browse files
committed
readline: refactor construct Interface
Remove the dependency on the arguments.length.
1 parent 9d493d0 commit c4a12c8

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
@@ -23,22 +23,13 @@ const stripVTControlCharacters = internalReadline.stripVTControlCharacters;
2323

2424

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

3529

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

4435
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)