Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1bd07ac

Browse filesBrowse files
claudiorodriguezMylesBorins
authored andcommitted
net: refactor onSlaveClose in Server.close
Refactors onSlaveClose in Server.close to be an arrow function, removes need for `self = this` and moves it down to make code more readable. PR-URL: #12334 Reviewed-By: Evan Lucas <evanlucas@me.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
1 parent bc64cf2 commit 1bd07ac
Copy full SHA for 1bd07ac

File tree

Expand file treeCollapse file tree

1 file changed

+6
-8
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-8
lines changed
Open diff view settings
Collapse file

‎lib/net.js‎

Copy file name to clipboardExpand all lines: lib/net.js
+6-8Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,13 +1495,6 @@ Server.prototype.getConnections = function(cb) {
14951495

14961496

14971497
Server.prototype.close = function(cb) {
1498-
function onSlaveClose() {
1499-
if (--left !== 0) return;
1500-
1501-
self._connections = 0;
1502-
self._emitCloseIfDrained();
1503-
}
1504-
15051498
if (typeof cb === 'function') {
15061499
if (!this._handle) {
15071500
this.once('close', function() {
@@ -1518,8 +1511,13 @@ Server.prototype.close = function(cb) {
15181511
}
15191512

15201513
if (this._usingSlaves) {
1521-
var self = this;
15221514
var left = this._slaves.length;
1515+
const onSlaveClose = () => {
1516+
if (--left !== 0) return;
1517+
1518+
this._connections = 0;
1519+
this._emitCloseIfDrained();
1520+
};
15231521

15241522
// Increment connections to be sure that, even if all sockets will be closed
15251523
// during polling of slaves, `close` event will be emitted only once.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.