From ec0dd6fa1cfa03b3983419acedb27ef95d297c82 Mon Sep 17 00:00:00 2001 From: James M Snell Date: Thu, 2 Jan 2020 14:01:10 -0800 Subject: [PATCH] lib: move GLOBAL and root aliases to EOL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GLOBAL and root have been long deprecated. PR-URL: https://github.com/nodejs/node/pull/31167 Reviewed-By: Gus Caplan Reviewed-By: Jiawen Geng Reviewed-By: Tobias Nießen Reviewed-By: Ruben Bridgewater Reviewed-By: Michaël Zasso Reviewed-By: Daniel Bevenius Reviewed-By: Matteo Collina --- doc/api/deprecations.md | 9 ++- lib/internal/bootstrap/node.js | 31 -------- test/parallel/test-util-inspect.js | 110 ++++++++++++++--------------- 3 files changed, 60 insertions(+), 90 deletions(-) diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 1023de0ec413ff..c225455b24d5ba 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -404,6 +404,9 @@ The [`fs.readSync()`][] legacy `String` interface is deprecated. Use the ### DEP0016: `GLOBAL`/`root` -Type: Runtime +Type: End-of-Life -The `GLOBAL` and `root` aliases for the `global` property are deprecated -and should no longer be used. +The `GLOBAL` and `root` aliases for the `global` property were deprecated +in Node.js 6.0.0 and have since been removed. ### DEP0017: `Intl.v8BreakIterator` diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index bb9a2b177c4304..aa166cc931b94f 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -40,7 +40,6 @@ setupPrepareStackTrace(); const { JSONParse, - ObjectDefineProperties, ObjectDefineProperty, ObjectGetPrototypeOf, ObjectSetPrototypeOf, @@ -294,36 +293,6 @@ function setupGlobalProxy() { enumerable: false, configurable: true }); - - function makeGetter(name) { - return deprecate(function() { - return this; - }, `'${name}' is deprecated, use 'global'`, 'DEP0016'); - } - - function makeSetter(name) { - return deprecate(function(value) { - ObjectDefineProperty(this, name, { - configurable: true, - writable: true, - enumerable: true, - value: value - }); - }, `'${name}' is deprecated, use 'global'`, 'DEP0016'); - } - - ObjectDefineProperties(global, { - GLOBAL: { - configurable: true, - get: makeGetter('GLOBAL'), - set: makeSetter('GLOBAL') - }, - root: { - configurable: true, - get: makeGetter('root'), - set: makeSetter('root') - } - }); } function setupBuffer() { diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 8c0cbc8d03dcc4..93d9f8a1bb6d6e 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -2532,24 +2532,23 @@ assert.strictEqual( 'unescape', 'eval', 'isFinite', 'isNaN', 'SharedArrayBuffer', 'Atomics', 'globalThis', 'WebAssembly', 'global', - 'process', 'GLOBAL', 'root', - 'Buffer', 'URL', 'URLSearchParams', - 'TextEncoder', 'TextDecoder', 'clearInterval', - 'clearTimeout', 'setInterval', 'setTimeout', - 'queueMicrotask', 'clearImmediate', 'setImmediate', - 'module', 'require', 'assert', - 'async_hooks', 'buffer', 'child_process', - 'cluster', 'crypto', 'dgram', - 'dns', 'domain', 'events', - 'fs', 'http', 'http2', - 'https', 'inspector', 'net', - 'os', 'path', 'perf_hooks', - 'punycode', 'querystring', 'readline', - 'repl', 'stream', 'string_decoder', - 'tls', 'trace_events', 'tty', - 'url', 'v8', 'vm', - 'worker_threads', 'zlib', '_', - '_error', 'util' + 'process', 'Buffer', 'URL', + 'URLSearchParams', 'TextEncoder', 'TextDecoder', + 'clearInterval', 'clearTimeout', 'setInterval', + 'setTimeout', 'queueMicrotask', 'clearImmediate', + 'setImmediate', 'module', 'require', + 'assert', 'async_hooks', 'buffer', + 'child_process', 'cluster', 'crypto', + 'dgram', 'dns', 'domain', + 'events', 'fs', 'http', + 'http2', 'https', 'inspector', + 'net', 'os', 'path', + 'perf_hooks', 'punycode', 'querystring', + 'readline', 'repl', 'stream', + 'string_decoder', 'tls', 'trace_events', + 'tty', 'url', 'v8', + 'vm', 'worker_threads', 'zlib', + '_', '_error', 'util' ]; out = util.inspect( @@ -2558,44 +2557,43 @@ assert.strictEqual( ); expected = [ '[', - " 'Object', 'Function', 'Array',", - " 'Number', 'parseFloat', 'parseInt',", - " 'Infinity', 'NaN', 'undefined',", - " 'Boolean', 'String', 'Symbol',", - " 'Date', 'Promise', 'RegExp',", - " 'Error', 'EvalError', 'RangeError',", - " 'ReferenceError', 'SyntaxError', 'TypeError',", - " 'URIError', 'JSON', 'Math',", - " 'console', 'Intl', 'ArrayBuffer',", - " 'Uint8Array', 'Int8Array', 'Uint16Array',", - " 'Int16Array', 'Uint32Array', 'Int32Array',", - " 'Float32Array', 'Float64Array', 'Uint8ClampedArray',", - " 'BigUint64Array', 'BigInt64Array', 'DataView',", - " 'Map', 'BigInt', 'Set',", - " 'WeakMap', 'WeakSet', 'Proxy',", - " 'Reflect', 'decodeURI', 'decodeURIComponent',", - " 'encodeURI', 'encodeURIComponent', 'escape',", - " 'unescape', 'eval', 'isFinite',", - " 'isNaN', 'SharedArrayBuffer', 'Atomics',", - " 'globalThis', 'WebAssembly', 'global',", - " 'process', 'GLOBAL', 'root',", - " 'Buffer', 'URL', 'URLSearchParams',", - " 'TextEncoder', 'TextDecoder', 'clearInterval',", - " 'clearTimeout', 'setInterval', 'setTimeout',", - " 'queueMicrotask', 'clearImmediate', 'setImmediate',", - " 'module', 'require', 'assert',", - " 'async_hooks', 'buffer', 'child_process',", - " 'cluster', 'crypto', 'dgram',", - " 'dns', 'domain', 'events',", - " 'fs', 'http', 'http2',", - " 'https', 'inspector', 'net',", - " 'os', 'path', 'perf_hooks',", - " 'punycode', 'querystring', 'readline',", - " 'repl', 'stream', 'string_decoder',", - " 'tls', 'trace_events', 'tty',", - " 'url', 'v8', 'vm',", - " 'worker_threads', 'zlib', '_',", - " '_error', 'util'", + " 'Object', 'Function', 'Array',", + " 'Number', 'parseFloat', 'parseInt',", + " 'Infinity', 'NaN', 'undefined',", + " 'Boolean', 'String', 'Symbol',", + " 'Date', 'Promise', 'RegExp',", + " 'Error', 'EvalError', 'RangeError',", + " 'ReferenceError', 'SyntaxError', 'TypeError',", + " 'URIError', 'JSON', 'Math',", + " 'console', 'Intl', 'ArrayBuffer',", + " 'Uint8Array', 'Int8Array', 'Uint16Array',", + " 'Int16Array', 'Uint32Array', 'Int32Array',", + " 'Float32Array', 'Float64Array', 'Uint8ClampedArray',", + " 'BigUint64Array', 'BigInt64Array', 'DataView',", + " 'Map', 'BigInt', 'Set',", + " 'WeakMap', 'WeakSet', 'Proxy',", + " 'Reflect', 'decodeURI', 'decodeURIComponent',", + " 'encodeURI', 'encodeURIComponent', 'escape',", + " 'unescape', 'eval', 'isFinite',", + " 'isNaN', 'SharedArrayBuffer', 'Atomics',", + " 'globalThis', 'WebAssembly', 'global',", + " 'process', 'Buffer', 'URL',", + " 'URLSearchParams', 'TextEncoder', 'TextDecoder',", + " 'clearInterval', 'clearTimeout', 'setInterval',", + " 'setTimeout', 'queueMicrotask', 'clearImmediate',", + " 'setImmediate', 'module', 'require',", + " 'assert', 'async_hooks', 'buffer',", + " 'child_process', 'cluster', 'crypto',", + " 'dgram', 'dns', 'domain',", + " 'events', 'fs', 'http',", + " 'http2', 'https', 'inspector',", + " 'net', 'os', 'path',", + " 'perf_hooks', 'punycode', 'querystring',", + " 'readline', 'repl', 'stream',", + " 'string_decoder', 'tls', 'trace_events',", + " 'tty', 'url', 'v8',", + " 'vm', 'worker_threads', 'zlib',", + " '_', '_error', 'util'", ']' ].join('\n');