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 b3acbc5

Browse filesBrowse 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 55319fe commit b3acbc5
Copy full SHA for b3acbc5

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
@@ -587,19 +587,27 @@ Socket.prototype._getpeername = function() {
587587
return this._peername;
588588
};
589589

590-
Socket.prototype.__defineGetter__('bytesRead', function() {
590+
function protoGetter(name, callback) {
591+
Object.defineProperty(Socket.prototype, name, {
592+
configurable: false,
593+
enumerable: true,
594+
get: callback
595+
});
596+
}
597+
598+
protoGetter('bytesRead', function bytesRead() {
591599
return this._handle ? this._handle.bytesRead : this[BYTES_READ];
592600
});
593601

594-
Socket.prototype.__defineGetter__('remoteAddress', function() {
602+
protoGetter('remoteAddress', function remoteAddress() {
595603
return this._getpeername().address;
596604
});
597605

598-
Socket.prototype.__defineGetter__('remoteFamily', function() {
606+
protoGetter('remoteFamily', function remoteFamily() {
599607
return this._getpeername().family;
600608
});
601609

602-
Socket.prototype.__defineGetter__('remotePort', function() {
610+
protoGetter('remotePort', function remotePort() {
603611
return this._getpeername().port;
604612
});
605613

@@ -618,12 +626,12 @@ Socket.prototype._getsockname = function() {
618626
};
619627

620628

621-
Socket.prototype.__defineGetter__('localAddress', function() {
629+
protoGetter('localAddress', function localAddress() {
622630
return this._getsockname().address;
623631
});
624632

625633

626-
Socket.prototype.__defineGetter__('localPort', function() {
634+
protoGetter('localPort', function localPort() {
627635
return this._getsockname().port;
628636
});
629637

@@ -735,7 +743,7 @@ function createWriteReq(req, handle, data, encoding) {
735743
}
736744

737745

738-
Socket.prototype.__defineGetter__('bytesWritten', function() {
746+
protoGetter('bytesWritten', function bytesWritten() {
739747
var bytes = this._bytesDispatched;
740748
const state = this._writableState;
741749
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.