Skip to content

lib: replace legacy uses of __defineGetter__ #6768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 36 additions & 15 deletions lib/_tls_legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -350,8 +350,12 @@ CryptoStream.prototype.setKeepAlive = function(enable, initialDelay) {
if (this.socket) this.socket.setKeepAlive(enable, initialDelay);
};

CryptoStream.prototype.__defineGetter__('bytesWritten', function() {
return this.socket ? this.socket.bytesWritten : 0;
Object.defineProperty(CryptoStream.prototype, 'bytesWritten', {
configurable: true,
enumerable: true,
get: function() {
return this.socket ? this.socket.bytesWritten : 0;
}
});

CryptoStream.prototype.getPeerCertificate = function(detailed) {
Expand Down Expand Up @@ -526,27 +530,44 @@ CleartextStream.prototype.address = function() {
return this.socket && this.socket.address();
};


CleartextStream.prototype.__defineGetter__('remoteAddress', function() {
return this.socket && this.socket.remoteAddress;
Object.defineProperty(CleartextStream.prototype, 'remoteAddress', {
configurable: true,
enumerable: true,
get: function() {
return this.socket && this.socket.remoteAddress;
}
});

CleartextStream.prototype.__defineGetter__('remoteFamily', function() {
return this.socket && this.socket.remoteFamily;
Object.defineProperty(CleartextStream.prototype, 'remoteFamily', {
configurable: true,
enumerable: true,
get: function() {
return this.socket && this.socket.remoteFamily;
}
});

CleartextStream.prototype.__defineGetter__('remotePort', function() {
return this.socket && this.socket.remotePort;
Object.defineProperty(CleartextStream.prototype, 'remotePort', {
configurable: true,
enumerable: true,
get: function() {
return this.socket && this.socket.remotePort;
}
});


CleartextStream.prototype.__defineGetter__('localAddress', function() {
return this.socket && this.socket.localAddress;
Object.defineProperty(CleartextStream.prototype, 'localAddress', {
configurable: true,
enumerable: true,
get: function() {
return this.socket && this.socket.localAddress;
}
});


CleartextStream.prototype.__defineGetter__('localPort', function() {
return this.socket && this.socket.localPort;
Object.defineProperty(CleartextStream.prototype, 'localPort', {
configurable: true,
enumerable: true,
get: function() {
return this.socket && this.socket.localPort;
}
});


Expand Down
21 changes: 14 additions & 7 deletions lib/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,13 +662,20 @@ function filterDuplicates(names) {
}

// Legacy API
exports.__defineGetter__('createCredentials',
internalUtil.deprecate(function() {
Object.defineProperty(exports, 'createCredentials', {
configurable: true,
enumerable: true,
get: internalUtil.deprecate(function() {
return require('tls').createSecureContext;
}, 'crypto.createCredentials is deprecated. ' +
'Use tls.createSecureContext instead.'));
'Use tls.createSecureContext instead.')
});

exports.__defineGetter__('Credentials', internalUtil.deprecate(function() {
return require('tls').SecureContext;
}, 'crypto.Credentials is deprecated. ' +
'Use tls.SecureContext instead.'));
Object.defineProperty(exports, 'Credentials', {
configurable: true,
enumerable: true,
get: internalUtil.deprecate(function() {
return require('tls').SecureContext;
}, 'crypto.Credentials is deprecated. ' +
'Use tls.SecureContext instead.')
});
8 changes: 6 additions & 2 deletions lib/internal/bootstrap_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,12 @@
}

function setupGlobalConsole() {
global.__defineGetter__('console', function() {
return NativeModule.require('console');
Object.defineProperty(global, 'console', {
configurable: true,
enumerable: true,
get: function() {
return NativeModule.require('console');
}
});
}

Expand Down
14 changes: 9 additions & 5 deletions lib/readline.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,15 @@ function Interface(input, output, completer, terminal) {

inherits(Interface, EventEmitter);

Interface.prototype.__defineGetter__('columns', function() {
var columns = Infinity;
if (this.output && this.output.columns)
columns = this.output.columns;
return columns;
Object.defineProperty(Interface.prototype, 'columns', {
configurable: true,
enumerable: true,
get: function() {
var columns = Infinity;
if (this.output && this.output.columns)
columns = this.output.columns;
return columns;
}
});

Interface.prototype.setPrompt = function(prompt) {
Expand Down