mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
readline: refactor construct Interface
Remove the dependency on the arguments.length. PR-URL: https://github.com/nodejs/node/pull/4740 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
This commit is contained in:
parent
6e7dfb1f45
commit
396688f075
|
|
@ -17,22 +17,13 @@ const EventEmitter = require('events');
|
|||
|
||||
|
||||
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._sawReturn = false;
|
||||
|
|
@ -41,7 +32,7 @@ function Interface(input, output, completer, terminal) {
|
|||
EventEmitter.call(this);
|
||||
var historySize;
|
||||
|
||||
if (arguments.length === 1) {
|
||||
if (input && input.input) {
|
||||
// an options object was given
|
||||
output = input.output;
|
||||
completer = input.completer;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user