From acbdbcf072c5bef83d97560a82bde91defb8d451 Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Sat, 30 May 2015 03:07:36 +0800 Subject: [PATCH] lib: remove variables root and GLOBAL The `root` and `GLOBAL` never be documented. --- src/node.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/node.js b/src/node.js index 065c337e743993..e3bb221b5e2877 100644 --- a/src/node.js +++ b/src/node.js @@ -159,8 +159,17 @@ startup.globalVariables = function() { global.process = process; global.global = global; - global.GLOBAL = global; - global.root = global; + + // Deprecate GLOBAL and root + const holders = {GLOBAL: global, root: global}; + ['GLOBAL', 'root'].forEach(function (name) { + const access = util.deprecate(function(val) { + if (val) holders[name] = val; + return holders[name]; + }, "'" + name + "' is deprecated, use 'global'"); + Object.defineProperty(global, name, {get: access, set: access}); + }); + global.Buffer = NativeModule.require('buffer').Buffer; process.domain = null; process._exiting = false;