Skip to content

Commit

Permalink
src: deprecate undocumented variables
Browse files Browse the repository at this point in the history
The `root` and `GLOBAL` never be documented.
  • Loading branch information
JacksonTian committed Feb 8, 2016
1 parent eaa9e0e commit 22e123b
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,27 @@
startup.globalVariables = function() {
global.process = process;
global.global = global;
global.GLOBAL = global;
global.root = global;
const util = NativeModule.require('util');

// 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;
process.domain = null;
process._exiting = false;
Expand Down

0 comments on commit 22e123b

Please sign in to comment.