@ -444,9 +444,7 @@ Socket.prototype.destroySoon = function() {
Socket . prototype . _ destroy = function ( exception , cb ) {
debug ( 'destroy' ) ;
var self = this ;
function fireErrorCallbacks ( ) {
function fireErrorCallbacks ( self ) {
if ( cb ) cb ( exception ) ;
if ( exception && ! self . _ writableState . errorEmitted ) {
process . nextTick ( emitErrorNT , self , exception ) ;
@ -456,11 +454,11 @@ Socket.prototype._destroy = function(exception, cb) {
if ( this . destroyed ) {
debug ( 'already destroyed, fire error callbacks' ) ;
fireErrorCallbacks ( ) ;
fireErrorCallbacks ( this ) ;
return ;
}
self . _ connecting = false ;
this . _ connecting = false ;
this . readable = this . writable = false ;
@ -472,9 +470,9 @@ Socket.prototype._destroy = function(exception, cb) {
if ( this !== process . stderr )
debug ( 'close handle' ) ;
var isException = exception ? true : false ;
this . _ handle . close ( function ( ) {
this . _ handle . close ( ( ) => {
debug ( 'emit close' ) ;
self . emit ( 'close' , isException ) ;
this . emit ( 'close' , isException ) ;
} ) ;
this . _ handle . onread = noop ;
this . _ handle = null ;
@ -485,7 +483,7 @@ Socket.prototype._destroy = function(exception, cb) {
// to make it re-entrance safe in case Socket.prototype.destroy()
// is called within callbacks
this . destroyed = true ;
fireErrorCallbacks ( ) ;
fireErrorCallbacks ( this ) ;
if ( this . _ server ) {
COUNTER_NET_SERVER_CONNECTION_CLOSE ( this ) ;
@ -1080,17 +1078,15 @@ function Server(options, connectionListener) {
EventEmitter . call ( this ) ;
var self = this ;
if ( typeof options === 'function' ) {
connectionListener = options ;
options = { } ;
self . on ( 'connection' , connectionListener ) ;
this . on ( 'connection' , connectionListener ) ;
} else if ( options == null || typeof options === 'object' ) {
options = options || { } ;
if ( typeof connectionListener === 'function' ) {
self . on ( 'connection' , connectionListener ) ;
this . on ( 'connection' , connectionListener ) ;
}
} else {
throw new TypeError ( 'options must be an object' ) ;
@ -1099,16 +1095,16 @@ function Server(options, connectionListener) {
this . _ connections = 0 ;
Object . defineProperty ( this , 'connections' , {
get : internalUtil . deprecate ( function ( ) {
get : internalUtil . deprecate ( ( ) => {
if ( self . _ usingSlaves ) {
if ( this . _ usingSlaves ) {
return null ;
}
return self . _ connections ;
return this . _ connections ;
} , 'Server.connections property is deprecated. ' +
'Use Server.getConnections method instead.' ) ,
set : internalUtil . deprecate ( function ( val ) {
return ( self . _ connections = val ) ;
set : internalUtil . deprecate ( ( val ) => {
return ( this . _ connections = val ) ;
} , 'Server.connections property is deprecated.' ) ,
configurable : true , enumerable : false
} ) ;