From 233d4f800a95cc844850acbdf30fa495d0bf6fc3 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..7259a7721d941f 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 = NativeModule.require('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;