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

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
@@ -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)
You are visitor 01402503 — 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.