-
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
Http: Improve finish()
callback and code legibility (Fixes #7295)
#7378
Conversation
Take advantage of arrow function lexical `this` to avoid defining a `self = this` var which was only used once.
Code relating to the `finish` event was split in to two areas of the parent function. Gathered it together to clarify association within the script. Fixes nodejs#7295
per jshint's request!
if (typeof callback === 'function') | ||
this.once('finish', callback); | ||
|
||
var finish = () => { |
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.
I think if better if in places like this you use const
instead var
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.
Agreed, will update PR shortly.
EDIT: Done.
Update based on PR feedback. nodejs#7378 (comment)
LGTM. Nothing else in |
LGTM |
/cc @nodejs/http |
LGTM |
1 similar comment
LGTM |
LGTM |
Take advantage of arrow function lexical `this` to avoid defining a `self = this` var which was only used once. Code relating to the `finish` event was split in to two areas of the parent function. Gathered it together to clarify association within the script. Fixes: #7295 PR-URL: #7378 Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Landed in 3c09d1b |
Take advantage of arrow function lexical `this` to avoid defining a `self = this` var which was only used once. Code relating to the `finish` event was split in to two areas of the parent function. Gathered it together to clarify association within the script. Fixes: #7295 PR-URL: #7378 Reviewed-By: Stephen Belanger <[email protected]> Reviewed-By: Brian White <[email protected]> Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
Checklist
make -j4 test
(UNIX) orvcbuild test nosign
(Windows) passesAffected core subsystem(s)
http
( Specifically
_http_outgoing.js
:OutgoingMessage.prototype.end
method )Description of change
this
.finish
event together to improve code clarity.this
? #7295 for further details.