summaryrefslogtreecommitdiff
path: root/lib/readline.js
diff options
context:
space:
mode:
authorAlex Kocharin <alex@kocharin.ru>2015-04-09 18:55:26 +0300
committerBen Noordhuis <info@bnoordhuis.nl>2015-04-10 10:56:19 +0200
commitf0bf6bb024f86412c2dbe6f0ea1f984a3a25ec2a (patch)
tree79565c2b2bee5f4f9b1728ab125aa9823b41e579 /lib/readline.js
parent8bc8bd4bc206d23fe8936608cdd5450cf037b586 (diff)
downloadnodejs-f0bf6bb024f86412c2dbe6f0ea1f984a3a25ec2a.tar.gz
nodejs-f0bf6bb024f86412c2dbe6f0ea1f984a3a25ec2a.tar.bz2
nodejs-f0bf6bb024f86412c2dbe6f0ea1f984a3a25ec2a.zip
readline: fix calling constructor without new
Previously, we detected options object based on amount of arguments supplied. But if we're calling readline without new operator, constructor gets re-called and will always have 4 arguments. PR-URL: https://github.com/iojs/io.js/pull/1385 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'lib/readline.js')
-rw-r--r--lib/readline.js5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/readline.js b/lib/readline.js
index 63a7aa816..a6845010d 100644
--- a/lib/readline.js
+++ b/lib/readline.js
@@ -26,7 +26,10 @@ exports.createInterface = function(input, output, completer, terminal) {
function Interface(input, output, completer, terminal) {
if (!(this instanceof Interface)) {
- return new Interface(input, output, completer, terminal);
+ // call the constructor preserving original number of arguments
+ const self = Object.create(Interface.prototype);
+ Interface.apply(self, arguments);
+ return self;
}
this._sawReturn = false;