-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Conversation
I hadn't noticed the Interface constructor before... what an odd way of initializing the object... this change looks good but let's see what CI says :-) |
LGTM |
CI failures look unrelated. LGTM |
I'm pretty sure it was related to backwards compat with a really old node version (0.6?). Definitely safe to remove at this point. |
7da4fd4
to
c7066fb
Compare
ci: https://ci.nodejs.org/job/node-test-pull-request/3021/ (rebased against master) @nodejs/collaborators PTAL |
LGTM. Let's try another CI: https://ci.nodejs.org/job/node-test-pull-request/3034/ |
one more CI. Will land later today if green https://ci.nodejs.org/job/node-test-pull-request/3178/ |
} | ||
|
||
this._sawReturn = false; | ||
|
||
EventEmitter.call(this); | ||
var historySize; | ||
|
||
if (arguments.length === 1) { | ||
if (input && input.input) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change in behaviour intentional? If input
is a custom implementation that happens to have an input
property, then it will cause the remaining arguments to be ignored. Can we find a safer way replicating the arguments length check? Maybe the ugly/obvious if (input && !output && !completer && !terminal)
approach would be the most appropriate?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks @rmg for scoping that out
thoughts @nodejs/collaborators?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, why not just keep arguments.length
check?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
arguments.length
wouldn't work with the way createInterface()
was refactored - it now always passes 4 args, even if they're undefined
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about changing it then to
exports.createInterface = (...args) => new Interface(...args);
?
That should solve the problem and, at the same time, still looks clean and elegant IMO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same should be applied for the constructor though, but not hard to do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
facepalm
this is targeting master, so I guess that's an option. Would also match lib/console.js
, now that I look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, given that Interface
allows calling itself without new
(and unless I'm missing something), it might be even reduced to exports.createInterface = Interface;
(in which case I don't really see why two separate methods are exported, unless we want to move Interface
to proper ES6 class and effectively break compatibility by forbidding calls without new
in future).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no. It doesn't change the behaviour. if (input && input.input) {
is used for check first argument is options
object.
c133999
to
83c7a88
Compare
Remove the dependency on the arguments.length.
a038a8a
to
c4a12c8
Compare
@MylesBorins @JacksonTian ... still want this? Looks like it fell through the cracks |
Yes. |
landed in dad98bf thanks all. |
Remove the dependency on the arguments.length. PR-URL: #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>
Remove the dependency on the arguments.length. PR-URL: nodejs#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>
Remove the dependency on the arguments.length. PR-URL: nodejs#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>
Remove the dependency on the arguments.length. PR-URL: nodejs#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>
Remove the dependency on the arguments.length. PR-URL: nodejs#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>
Remove the dependency on the arguments.length. PR-URL: #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>
Remove the dependency on the arguments.length. PR-URL: #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>
I've gone ahead and landed this into lts staging. Please let me know if it should be taken out |
Remove the dependency on the arguments.length. PR-URL: #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>
Remove the dependency on the arguments.length. PR-URL: #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>
Remove the dependency on the arguments.length.