From 4e4693140698eeb1b45e682a577142bcde2bd7be Mon Sep 17 00:00:00 2001 From: Jackson Tian Date: Sat, 30 May 2015 03:07:36 +0800 Subject: [PATCH] src: deprecate undocumented variables MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `root` and `GLOBAL` were never documented. PR-URL: https://github.com/nodejs/node/pull/1838 Reviewed-By: Ben Noordhuis Reviewed-By: Colin Ihrig Reviewed-By: James M Snell Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Roman Reiss Reviewed By: Sakthipriyan Vairamani --- src/node.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/node.js b/src/node.js index 40ae7cacff5228..ec0e6bf630b5e1 100644 --- a/src/node.js +++ b/src/node.js @@ -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;