Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readline: refactor construct Interface #4740

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 3 additions & 12 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,13 @@ const stripVTControlCharacters = internalReadline.stripVTControlCharacters;


exports.createInterface = function(input, output, completer, terminal) {
var rl;
if (arguments.length === 1) {
rl = new Interface(input);
} else {
rl = new Interface(input, output, completer, terminal);
}
return rl;
return new Interface(input, output, completer, terminal);
};


function Interface(input, output, completer, terminal) {
if (!(this instanceof Interface)) {
// call the constructor preserving original number of arguments
const self = Object.create(Interface.prototype);
Interface.apply(self, arguments);
return self;
return new Interface(input, output, completer, terminal);
}

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

if (arguments.length === 1) {
if (input && input.input) {
// an options object was given
output = input.output;
completer = input.completer;
Expand Down