Skip to content

Commit 396688f

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 6e7dfb1 commit 396688f

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
@@ -17,22 +17,13 @@ const EventEmitter = require('events');
1717

1818

1919
exports.createInterface = function(input, output, completer, terminal) {
20-
var rl;
21-
if (arguments.length === 1) {
22-
rl = new Interface(input);
23-
} else {
24-
rl = new Interface(input, output, completer, terminal);
25-
}
26-
return rl;
20+
return new Interface(input, output, completer, terminal);
2721
};
2822

2923

3024
function Interface(input, output, completer, terminal) {
3125
if (!(this instanceof Interface)) {
32-
// call the constructor preserving original number of arguments
33-
const self = Object.create(Interface.prototype);
34-
Interface.apply(self, arguments);
35-
return self;
26+
return new Interface(input, output, completer, terminal);
3627
}
3728

3829
this._sawReturn = false;
@@ -41,7 +32,7 @@ function Interface(input, output, completer, terminal) {
4132
EventEmitter.call(this);
4233
var historySize;
4334

44-
if (arguments.length === 1) {
35+
if (input && input.input) {
4536
// an options object was given
4637
output = input.output;
4738
completer = input.completer;

0 commit comments

Comments
 (0)