Skip to content

Commit d5d4f19

Browse files
indutnyMyles Borins
authored andcommitted
net: replace __defineGetter__ with defineProperty
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: #6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
1 parent 20dcdd3 commit d5d4f19

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

‎lib/net.js‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -585,19 +585,27 @@ Socket.prototype._getpeername = function() {
585585
returnthis._peername;
586586
};
587587

588-
Socket.prototype.__defineGetter__('bytesRead',function(){
588+
functionprotoGetter(name,callback){
589+
Object.defineProperty(Socket.prototype,name,{
590+
configurable: false,
591+
enumerable: true,
592+
get: callback
593+
});
594+
}
595+
596+
protoGetter('bytesRead',functionbytesRead(){
589597
returnthis._handle ? this._handle.bytesRead : this[BYTES_READ];
590598
});
591599

592-
Socket.prototype.__defineGetter__('remoteAddress',function(){
600+
protoGetter('remoteAddress',functionremoteAddress(){
593601
returnthis._getpeername().address;
594602
});
595603

596-
Socket.prototype.__defineGetter__('remoteFamily',function(){
604+
protoGetter('remoteFamily',functionremoteFamily(){
597605
returnthis._getpeername().family;
598606
});
599607

600-
Socket.prototype.__defineGetter__('remotePort',function(){
608+
protoGetter('remotePort',functionremotePort(){
601609
returnthis._getpeername().port;
602610
});
603611

@@ -616,12 +624,12 @@ Socket.prototype._getsockname = function() {
616624
};
617625

618626

619-
Socket.prototype.__defineGetter__('localAddress',function(){
627+
protoGetter('localAddress',functionlocalAddress(){
620628
returnthis._getsockname().address;
621629
});
622630

623631

624-
Socket.prototype.__defineGetter__('localPort',function(){
632+
protoGetter('localPort',functionlocalPort(){
625633
returnthis._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',functionbytesWritten(){
737745
varbytes=this._bytesDispatched;
738746
conststate=this._writableState;
739747
constdata=this._pendingData;

0 commit comments

Comments
 (0)