@@ -585,19 +585,27 @@ Socket.prototype._getpeername = function() {
585585 return this . _peername ;
586586} ;
587587
588- Socket . prototype . __defineGetter__ ( 'bytesRead' , function ( ) {
588+ function protoGetter ( name , callback ) {
589+ Object . defineProperty ( Socket . prototype , name , {
590+ configurable : false ,
591+ enumerable : true ,
592+ get : callback
593+ } ) ;
594+ }
595+
596+ protoGetter ( 'bytesRead' , function bytesRead ( ) {
589597 return this . _handle ? this . _handle . bytesRead : this [ BYTES_READ ] ;
590598} ) ;
591599
592- Socket . prototype . __defineGetter__ ( 'remoteAddress' , function ( ) {
600+ protoGetter ( 'remoteAddress' , function remoteAddress ( ) {
593601 return this . _getpeername ( ) . address ;
594602} ) ;
595603
596- Socket . prototype . __defineGetter__ ( 'remoteFamily' , function ( ) {
604+ protoGetter ( 'remoteFamily' , function remoteFamily ( ) {
597605 return this . _getpeername ( ) . family ;
598606} ) ;
599607
600- Socket . prototype . __defineGetter__ ( 'remotePort' , function ( ) {
608+ protoGetter ( 'remotePort' , function remotePort ( ) {
601609 return this . _getpeername ( ) . port ;
602610} ) ;
603611
@@ -616,12 +624,12 @@ Socket.prototype._getsockname = function() {
616624} ;
617625
618626
619- Socket . prototype . __defineGetter__ ( 'localAddress' , function ( ) {
627+ protoGetter ( 'localAddress' , function localAddress ( ) {
620628 return this . _getsockname ( ) . address ;
621629} ) ;
622630
623631
624- Socket . prototype . __defineGetter__ ( 'localPort' , function ( ) {
632+ protoGetter ( 'localPort' , function localPort ( ) {
625633 return this . _getsockname ( ) . port ;
626634} ) ;
627635
@@ -733,7 +741,7 @@ function createWriteReq(req, handle, data, encoding) {
733741}
734742
735743
736- Socket . prototype . __defineGetter__ ( 'bytesWritten' , function ( ) {
744+ protoGetter ( 'bytesWritten' , function bytesWritten ( ) {
737745 var bytes = this . _bytesDispatched ;
738746 const state = this . _writableState ;
739747 const data = this . _pendingData ;
0 commit comments