@@ -444,9 +444,7 @@ Socket.prototype.destroySoon = function() {
444444Socket . prototype . _destroy = function ( exception , cb ) {
445445 debug ( 'destroy' ) ;
446446
447- var self = this ;
448-
449- function fireErrorCallbacks ( ) {
447+ function fireErrorCallbacks ( self ) {
450448 if ( cb ) cb ( exception ) ;
451449 if ( exception && ! self . _writableState . errorEmitted ) {
452450 process . nextTick ( emitErrorNT , self , exception ) ;
@@ -456,11 +454,11 @@ Socket.prototype._destroy = function(exception, cb) {
456454
457455 if ( this . destroyed ) {
458456 debug ( 'already destroyed, fire error callbacks' ) ;
459- fireErrorCallbacks ( ) ;
457+ fireErrorCallbacks ( this ) ;
460458 return ;
461459 }
462460
463- self . _connecting = false ;
461+ this . _connecting = false ;
464462
465463 this . readable = this . writable = false ;
466464
@@ -472,9 +470,9 @@ Socket.prototype._destroy = function(exception, cb) {
472470 if ( this !== process . stderr )
473471 debug ( 'close handle' ) ;
474472 var isException = exception ? true : false ;
475- this . _handle . close ( function ( ) {
473+ this . _handle . close ( ( ) => {
476474 debug ( 'emit close' ) ;
477- self . emit ( 'close' , isException ) ;
475+ this . emit ( 'close' , isException ) ;
478476 } ) ;
479477 this . _handle . onread = noop ;
480478 this . _handle = null ;
@@ -485,7 +483,7 @@ Socket.prototype._destroy = function(exception, cb) {
485483 // to make it re-entrance safe in case Socket.prototype.destroy()
486484 // is called within callbacks
487485 this . destroyed = true ;
488- fireErrorCallbacks ( ) ;
486+ fireErrorCallbacks ( this ) ;
489487
490488 if ( this . _server ) {
491489 COUNTER_NET_SERVER_CONNECTION_CLOSE ( this ) ;
@@ -1078,33 +1076,31 @@ function Server(options, connectionListener) {
10781076
10791077 EventEmitter . call ( this ) ;
10801078
1081- var self = this ;
1082-
10831079 if ( typeof options === 'function' ) {
10841080 connectionListener = options ;
10851081 options = { } ;
1086- self . on ( 'connection' , connectionListener ) ;
1082+ this . on ( 'connection' , connectionListener ) ;
10871083 } else {
10881084 options = options || { } ;
10891085
10901086 if ( typeof connectionListener === 'function' ) {
1091- self . on ( 'connection' , connectionListener ) ;
1087+ this . on ( 'connection' , connectionListener ) ;
10921088 }
10931089 }
10941090
10951091 this . _connections = 0 ;
10961092
10971093 Object . defineProperty ( this , 'connections' , {
1098- get : internalUtil . deprecate ( function ( ) {
1094+ get : internalUtil . deprecate ( ( ) => {
10991095
1100- if ( self . _usingSlaves ) {
1096+ if ( this . _usingSlaves ) {
11011097 return null ;
11021098 }
1103- return self . _connections ;
1099+ return this . _connections ;
11041100 } , 'Server.connections property is deprecated. ' +
11051101 'Use Server.getConnections method instead.' ) ,
1106- set : internalUtil . deprecate ( function ( val ) {
1107- return ( self . _connections = val ) ;
1102+ set : internalUtil . deprecate ( ( val ) => {
1103+ return ( this . _connections = val ) ;
11081104 } , 'Server.connections property is deprecated.' ) ,
11091105 configurable : true , enumerable : false
11101106 } ) ;
0 commit comments