From 22e123b823fb66490f8f801c7872f4141afe9839 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 The `root` and `GLOBAL` never be documented. --- src/node.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/src/node.js b/src/node.js index cdb147d4f92959..1deaa6de5e22db 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;