summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorFedor Indutny <fedor@indutny.com>2016-04-20 11:59:16 -0400
committerJames M Snell <jasnell@gmail.com>2016-04-26 12:16:26 -0700
commit8db8a4bc2ca815d85122c8d6ff1aa493c10cd6cb (patch)
tree7eec571168f6032fb5471dc40a70242f98d1977f /lib
parent479344f69537a833c410b178154dd0fd4ddcb8e7 (diff)
downloadnode-new-8db8a4bc2ca815d85122c8d6ff1aa493c10cd6cb.tar.gz
net: replace __defineGetter__ with defineProperty
`Object.prototype.__defineGetter__` is deprecated now, use `Object.defineProperty` instead. PR-URL: https://github.com/nodejs/node/pull/6284 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'lib')
-rw-r--r--lib/net.js22
1 files changed, 15 insertions, 7 deletions
diff --git a/lib/net.js b/lib/net.js
index e3b726a756..3c87ac29d2 100644
--- a/lib/net.js
+++ b/lib/net.js
@@ -585,19 +585,27 @@ Socket.prototype._getpeername = function() {
return this._peername;
};
-Socket.prototype.__defineGetter__('bytesRead', function() {
+function protoGetter(name, callback) {
+ Object.defineProperty(Socket.prototype, name, {
+ configurable: false,
+ enumerable: true,
+ get: callback
+ });
+}
+
+protoGetter('bytesRead', function bytesRead() {
return this._handle ? this._handle.bytesRead : this[BYTES_READ];
});
-Socket.prototype.__defineGetter__('remoteAddress', function() {
+protoGetter('remoteAddress', function remoteAddress() {
return this._getpeername().address;
});
-Socket.prototype.__defineGetter__('remoteFamily', function() {
+protoGetter('remoteFamily', function remoteFamily() {
return this._getpeername().family;
});
-Socket.prototype.__defineGetter__('remotePort', function() {
+protoGetter('remotePort', function remotePort() {
return this._getpeername().port;
});
@@ -616,12 +624,12 @@ Socket.prototype._getsockname = function() {
};
-Socket.prototype.__defineGetter__('localAddress', function() {
+protoGetter('localAddress', function localAddress() {
return this._getsockname().address;
});
-Socket.prototype.__defineGetter__('localPort', function() {
+protoGetter('localPort', function localPort() {
return this._getsockname().port;
});
@@ -735,7 +743,7 @@ function createWriteReq(req, handle, data, encoding) {
}
-Socket.prototype.__defineGetter__('bytesWritten', function() {
+protoGetter('bytesWritten', function bytesWritten() {
var bytes = this._bytesDispatched;
const state = this._writableState;
const data = this._pendingData;