FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Http: Improve `finish()` callback and code legibility (Fixes #7295) by originalfoo · Pull Request #7378 · nodejs/node · GitHub

/ node Public

Http: Improve finish() callback and code legibility (Fixes #7295) - #7378

Closed
originalfoo wants to merge 4 commits into
nodejs:masterfrom
originalfoo:http-outgoing-7295
Closed

Http: Improve finish() callback and code legibility (Fixes #7295)#7378
originalfoo wants to merge 4 commits into
nodejs:masterfrom
originalfoo:http-outgoing-7295

Conversation

Copy link
Copy Markdown
Contributor
Checklist
  • make -j4 test (UNIX) or vcbuild test nosign (Windows) passes
  • the commit message follows commit guidelines
Affected core subsystem(s)

http

( Specifically _http_outgoing.js: OutgoingMessage.prototype.end method )

Description of change
  1. Converted callback function to arrow function to take advantage of lexical this.
  2. Gathered code relating to finish event together to improve code clarity.
  3. See http: use arrow function to take advantage of lexical this? #7295 for further details.

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
nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Jun 23, 2016
Comment thread lib/_http_outgoing.js Outdated
if (typeof callback === 'function')
this.once('finish', callback);

var finish = () => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think if better if in places like this you use const instead var

originalfoo Jun 23, 2016
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Agreed, will update PR shortly.

EDIT: Done.

mscdex commented Jun 23, 2016

Copy link
Copy Markdown
Contributor

Qard commented Jun 23, 2016
edited
Loading

Copy link
Copy Markdown
Member

LGTM. Nothing else in _http_* emits 'finish' in the other code paths of that function, so it should be all good. 👍

mscdex commented Jun 23, 2016

Copy link
Copy Markdown
Contributor

LGTM

mscdex commented Jun 23, 2016

Copy link
Copy Markdown
Contributor

/cc @nodejs/http

indutny commented Jun 23, 2016

Copy link
Copy Markdown
Member

LGTM

1 similar comment

cjihrig commented Jun 23, 2016

Copy link
Copy Markdown
Contributor

LGTM

jasnell commented Jun 27, 2016

Copy link
Copy Markdown
Member

LGTM

jasnell pushed a commit that referenced this pull request Jun 27, 2016
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 <admin@stephenbelanger.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>

jasnell commented Jun 27, 2016

Copy link
Copy Markdown
Member

Landed in 3c09d1b

jasnell closed this Jun 27, 2016
Fishrock123 pushed a commit that referenced this pull request Jul 5, 2016
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 <admin@stephenbelanger.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Fishrock123 mentioned this pull request Jul 5, 2016
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

http Issues or PRs related to the http subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants


Back | FazBrowse Home | New Git URL