From 396688f075a9b052c75436e45858f9ff45b22247 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Mon, 18 Jan 2016 17:51:15 +0800 Subject: [PATCH] readline: refactor construct Interface Remove the dependency on the arguments.length. PR-URL: https://github.com/nodejs/node/pull/4740 Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Trevor Norris Reviewed-By: Benjamin Gruenbaum --- lib/readline.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/lib/readline.js b/lib/readline.js index 546dfb173eb8fa..66ba46da354ff8 100644 --- a/lib/readline.js +++ b/lib/readline.js @@ -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;