GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — net: replace __defineGetter__ with defineProperty · nodejs/node@b3acbc5

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib
    • net.js
Expand file treeCollapse file tree
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)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.