@@ -587,19 +587,27 @@ Socket.prototype._getpeername = function() { |
587 | 587 | return this._peername; |
588 | 588 | }; |
589 | 589 |
|
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() { |
591 | 599 | return this._handle ? this._handle.bytesRead : this[BYTES_READ]; |
592 | 600 | }); |
593 | 601 |
|
594 | | -Socket.prototype.__defineGetter__('remoteAddress', function() { |
| 602 | +protoGetter('remoteAddress', function remoteAddress() { |
595 | 603 | return this._getpeername().address; |
596 | 604 | }); |
597 | 605 |
|
598 | | -Socket.prototype.__defineGetter__('remoteFamily', function() { |
| 606 | +protoGetter('remoteFamily', function remoteFamily() { |
599 | 607 | return this._getpeername().family; |
600 | 608 | }); |
601 | 609 |
|
602 | | -Socket.prototype.__defineGetter__('remotePort', function() { |
| 610 | +protoGetter('remotePort', function remotePort() { |
603 | 611 | return this._getpeername().port; |
604 | 612 | }); |
605 | 613 |
|
@@ -618,12 +626,12 @@ Socket.prototype._getsockname = function() { |
618 | 626 | }; |
619 | 627 |
|
620 | 628 |
|
621 | | -Socket.prototype.__defineGetter__('localAddress', function() { |
| 629 | +protoGetter('localAddress', function localAddress() { |
622 | 630 | return this._getsockname().address; |
623 | 631 | }); |
624 | 632 |
|
625 | 633 |
|
626 | | -Socket.prototype.__defineGetter__('localPort', function() { |
| 634 | +protoGetter('localPort', function localPort() { |
627 | 635 | return this._getsockname().port; |
628 | 636 | }); |
629 | 637 |
|
@@ -735,7 +743,7 @@ function createWriteReq(req, handle, data, encoding) { |
735 | 743 | } |
736 | 744 |
|
737 | 745 |
|
738 | | -Socket.prototype.__defineGetter__('bytesWritten', function() { |
| 746 | +protoGetter('bytesWritten', function bytesWritten() { |
739 | 747 | var bytes = this._bytesDispatched; |
740 | 748 | const state = this._writableState; |
741 | 749 | const data = this._pendingData; |
|