From 63f0d860865bf126025c018076dfc3231d8952e5 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 | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/node.js b/src/node.js index 065c337e743993..4becfa978d5e12 100644 --- a/src/node.js +++ b/src/node.js @@ -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;