lib: replace legacy uses of __defineGetter__
Minor clean up. There are still some places in core that use the legacy __defineGetter__ syntax. This updates most of those. PR-URL: https://github.com/nodejs/node/pull/6768 Reviewed-By: Rich Trott <rtrott@gmail.com>
This commit is contained in:
parent
78520fa472
commit
f293d0b0c8
@ -350,8 +350,12 @@ CryptoStream.prototype.setKeepAlive = function(enable, initialDelay) {
|
|||||||
if (this.socket) this.socket.setKeepAlive(enable, initialDelay);
|
if (this.socket) this.socket.setKeepAlive(enable, initialDelay);
|
||||||
};
|
};
|
||||||
|
|
||||||
CryptoStream.prototype.__defineGetter__('bytesWritten', function() {
|
Object.defineProperty(CryptoStream.prototype, 'bytesWritten', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get: function() {
|
||||||
return this.socket ? this.socket.bytesWritten : 0;
|
return this.socket ? this.socket.bytesWritten : 0;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CryptoStream.prototype.getPeerCertificate = function(detailed) {
|
CryptoStream.prototype.getPeerCertificate = function(detailed) {
|
||||||
@ -526,27 +530,44 @@ CleartextStream.prototype.address = function() {
|
|||||||
return this.socket && this.socket.address();
|
return this.socket && this.socket.address();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Object.defineProperty(CleartextStream.prototype, 'remoteAddress', {
|
||||||
CleartextStream.prototype.__defineGetter__('remoteAddress', function() {
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get: function() {
|
||||||
return this.socket && this.socket.remoteAddress;
|
return this.socket && this.socket.remoteAddress;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CleartextStream.prototype.__defineGetter__('remoteFamily', function() {
|
Object.defineProperty(CleartextStream.prototype, 'remoteFamily', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get: function() {
|
||||||
return this.socket && this.socket.remoteFamily;
|
return this.socket && this.socket.remoteFamily;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
CleartextStream.prototype.__defineGetter__('remotePort', function() {
|
Object.defineProperty(CleartextStream.prototype, 'remotePort', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get: function() {
|
||||||
return this.socket && this.socket.remotePort;
|
return this.socket && this.socket.remotePort;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Object.defineProperty(CleartextStream.prototype, 'localAddress', {
|
||||||
CleartextStream.prototype.__defineGetter__('localAddress', function() {
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get: function() {
|
||||||
return this.socket && this.socket.localAddress;
|
return this.socket && this.socket.localAddress;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Object.defineProperty(CleartextStream.prototype, 'localPort', {
|
||||||
CleartextStream.prototype.__defineGetter__('localPort', function() {
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get: function() {
|
||||||
return this.socket && this.socket.localPort;
|
return this.socket && this.socket.localPort;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -662,13 +662,20 @@ function filterDuplicates(names) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Legacy API
|
// Legacy API
|
||||||
exports.__defineGetter__('createCredentials',
|
Object.defineProperty(exports, 'createCredentials', {
|
||||||
internalUtil.deprecate(function() {
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get: internalUtil.deprecate(function() {
|
||||||
return require('tls').createSecureContext;
|
return require('tls').createSecureContext;
|
||||||
}, 'crypto.createCredentials is deprecated. ' +
|
}, 'crypto.createCredentials is deprecated. ' +
|
||||||
'Use tls.createSecureContext instead.'));
|
'Use tls.createSecureContext instead.')
|
||||||
|
});
|
||||||
|
|
||||||
exports.__defineGetter__('Credentials', internalUtil.deprecate(function() {
|
Object.defineProperty(exports, 'Credentials', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get: internalUtil.deprecate(function() {
|
||||||
return require('tls').SecureContext;
|
return require('tls').SecureContext;
|
||||||
}, 'crypto.Credentials is deprecated. ' +
|
}, 'crypto.Credentials is deprecated. ' +
|
||||||
'Use tls.SecureContext instead.'));
|
'Use tls.SecureContext instead.')
|
||||||
|
});
|
||||||
|
6
lib/internal/bootstrap_node.js
vendored
6
lib/internal/bootstrap_node.js
vendored
@ -251,8 +251,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function setupGlobalConsole() {
|
function setupGlobalConsole() {
|
||||||
global.__defineGetter__('console', function() {
|
Object.defineProperty(global, 'console', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get: function() {
|
||||||
return NativeModule.require('console');
|
return NativeModule.require('console');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,11 +165,15 @@ function Interface(input, output, completer, terminal) {
|
|||||||
|
|
||||||
inherits(Interface, EventEmitter);
|
inherits(Interface, EventEmitter);
|
||||||
|
|
||||||
Interface.prototype.__defineGetter__('columns', function() {
|
Object.defineProperty(Interface.prototype, 'columns', {
|
||||||
|
configurable: true,
|
||||||
|
enumerable: true,
|
||||||
|
get: function() {
|
||||||
var columns = Infinity;
|
var columns = Infinity;
|
||||||
if (this.output && this.output.columns)
|
if (this.output && this.output.columns)
|
||||||
columns = this.output.columns;
|
columns = this.output.columns;
|
||||||
return columns;
|
return columns;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Interface.prototype.setPrompt = function(prompt) {
|
Interface.prototype.setPrompt = function(prompt) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user