-
-
Notifications
You must be signed in to change notification settings - Fork 33.9k
Closed
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.
Description
- Version: 6.2.1
- Platform:
- Subsystem: lib/_http_outgoing.js
In OutgoingMessage.prototype.end there's a self var that's only used once for the finish() function - would it be better to use an arrow function instead?
Current code: https://github.com/nodejs/node/blob/master/lib/_http_outgoing.js#L549
var self = this;
function finish() {
self.emit('finish');
}Proposed change:
let finish = () => this.emit('finish'); // lexical `this`Also, as the finish() function isn't used until the code around L584, would it be worth moving the function closer to where it's used (along with the callback check) to aid code clarity?
// keep these 3 blocks together as they are related
let finish = () => this.emit('finish');
if (typeof callback === 'function')
this.once('finish', callback);
if (this._hasBody && this.chunkedEncoding) {
ret = this._send('0\r\n' + this._trailer + '\r\n', 'latin1', finish);
} else {
// Force a flush, HACK.
ret = this._send('', 'latin1', finish);
}coderaiser and Qard
Metadata
Metadata
Assignees
Labels
httpIssues or PRs related to the http subsystem.Issues or PRs related to the http subsystem.