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 36c58da

Browse filesBrowse files
indutnyMylesBorins
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 052d87c commit 36c58da
Copy full SHA for 36c58da

File tree

Expand file treeCollapse file tree

1 file changed

+15
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+15
-7
lines changed
Open diff view settings
Collapse file

‎lib/net.js‎

Copy file name to clipboardExpand all lines: lib/net.js
+15-7Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

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