Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 34.2k
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
varself=this;functionfinish(){self.emit('finish');}Proposed change:
letfinish=()=>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 relatedletfinish=()=>this.emit('finish');if(typeofcallback==='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.