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 Jun 1, 2015
1 parent 2c686fd commit 63f0d86
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions src/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,28 @@
startup.globalVariables = function() {
global.process = process;
global.global = global;
global.GLOBAL = global;
global.root = global;

// Deprecate GLOBAL and root
['GLOBAL', 'root'].forEach(function (name) {
// getter
const get = NativeModule.require('util').deprecate(function() {
const desc = { configurable: true, enumerable: true, value: this };
Object.defineProperty(this, 'GLOBAL', desc);
return this;
}, "'" + name + "' is deprecated, use 'global'");
// setter
const set = function(value) {
const desc = { configurable: true, enumerable: true, value: value };
Object.defineProperty(this, name, desc);
};
// define property
Object.defineProperty(global, name, {
configurable: true, // but not enumerable
get: get,
set: set
});
});

global.Buffer = NativeModule.require('buffer').Buffer;
process.domain = null;
process._exiting = false;
Expand Down

0 comments on commit 63f0d86

Please sign in to comment.