lib: replace legacy uses of __defineGetter__ · nodejs/node@74582aa · GitHub
Skip to content

Commit 74582aa

Browse files
jasnellevanlucas
authored andcommitted
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: #6768 Reviewed-By: Rich Trott <rtrott@gmail.com>
1 parent 897934a commit 74582aa

4 files changed

Lines changed: 65 additions & 29 deletions

File tree

lib/_tls_legacy.js

Lines changed: 36 additions & 15 deletions

lib/crypto.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -662,13 +662,20 @@ function filterDuplicates(names) {
662662
}
663663

664664
// Legacy API
665-
exports.__defineGetter__('createCredentials',
666-
internalUtil.deprecate(function() {
665+
Object.defineProperty(exports, 'createCredentials', {
666+
configurable: true,
667+
enumerable: true,
668+
get: internalUtil.deprecate(function() {
667669
return require('tls').createSecureContext;
668670
}, 'crypto.createCredentials is deprecated. ' +
669-
'Use tls.createSecureContext instead.'));
671+
'Use tls.createSecureContext instead.')
672+
});
670673

671-
exports.__defineGetter__('Credentials', internalUtil.deprecate(function() {
672-
return require('tls').SecureContext;
673-
}, 'crypto.Credentials is deprecated. ' +
674-
'Use tls.SecureContext instead.'));
674+
Object.defineProperty(exports, 'Credentials', {
675+
configurable: true,
676+
enumerable: true,
677+
get: internalUtil.deprecate(function() {
678+
return require('tls').SecureContext;
679+
}, 'crypto.Credentials is deprecated. ' +
680+
'Use tls.SecureContext instead.')
681+
});

lib/internal/bootstrap_node.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,12 @@
251251
}
252252

253253
function setupGlobalConsole() {
254-
global.__defineGetter__('console', function() {
255-
return NativeModule.require('console');
254+
Object.defineProperty(global, 'console', {
255+
configurable: true,
256+
enumerable: true,
257+
get: function() {
258+
return NativeModule.require('console');
259+
}
256260
});
257261
}
258262

lib/readline.js

Lines changed: 9 additions & 5 deletions

0 commit comments

Comments
 (0)