src: deprecate undocumented variables

The `root` and `GLOBAL` were never documented.

PR-URL: https://github.com/nodejs/node/pull/1838
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This commit is contained in:
Jackson Tian 2015-05-30 03:07:36 +08:00 committed by Ben Noordhuis
parent b212be08f6
commit 4e46931406

View File

@ -222,8 +222,27 @@
startup.globalVariables = function() { startup.globalVariables = function() {
global.process = process; global.process = process;
global.global = global; global.global = global;
global.GLOBAL = global; const util = NativeModule.require('util');
global.root = global;
// Deprecate GLOBAL and root
['GLOBAL', 'root'].forEach(function(name) {
// getter
const get = util.deprecate(function() {
return this;
}, `'${name}' is deprecated, use 'global'`);
// setter
const set = util.deprecate(function(value) {
Object.defineProperty(this, name, {
configurable: true,
writable: true,
enumerable: true,
value: value
});
}, `'${name}' is deprecated, use 'global'`);
// define property
Object.defineProperty(global, name, { get, set, configurable: true });
});
global.Buffer = NativeModule.require('buffer').Buffer; global.Buffer = NativeModule.require('buffer').Buffer;
process.domain = null; process.domain = null;
process._exiting = false; process._exiting = false;