@@ -45,6 +45,7 @@ const {
4545 ObjectGetPrototypeOf,
4646 ObjectSetPrototypeOf,
4747 SymbolToStringTag,
48+ globalThis,
4849} = primordials ;
4950const config = internalBinding ( 'config' ) ;
5051const { deprecate } = require ( 'internal/util' ) ;
@@ -119,34 +120,35 @@ if (!config.noBrowserGlobals) {
119120 // Override global console from the one provided by the VM
120121 // to the one implemented by Node.js
121122 // https://console.spec.whatwg.org/#console-namespace
122- exposeNamespace ( global , 'console' , createGlobalConsole ( global . console ) ) ;
123+ exposeNamespace ( globalThis , 'console' ,
124+ createGlobalConsole ( globalThis . console ) ) ;
123125
124126 const { URL , URLSearchParams } = require ( 'internal/url' ) ;
125127 // https://url.spec.whatwg.org/#url
126- exposeInterface ( global , 'URL' , URL ) ;
128+ exposeInterface ( globalThis , 'URL' , URL ) ;
127129 // https://url.spec.whatwg.org/#urlsearchparams
128- exposeInterface ( global , 'URLSearchParams' , URLSearchParams ) ;
130+ exposeInterface ( globalThis , 'URLSearchParams' , URLSearchParams ) ;
129131
130132 const {
131133 TextEncoder, TextDecoder
132134 } = require ( 'internal/encoding' ) ;
133135 // https://encoding.spec.whatwg.org/#textencoder
134- exposeInterface ( global , 'TextEncoder' , TextEncoder ) ;
136+ exposeInterface ( globalThis , 'TextEncoder' , TextEncoder ) ;
135137 // https://encoding.spec.whatwg.org/#textdecoder
136- exposeInterface ( global , 'TextDecoder' , TextDecoder ) ;
138+ exposeInterface ( globalThis , 'TextDecoder' , TextDecoder ) ;
137139
138140 // https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope
139141 const timers = require ( 'timers' ) ;
140- defineOperation ( global , 'clearInterval' , timers . clearInterval ) ;
141- defineOperation ( global , 'clearTimeout' , timers . clearTimeout ) ;
142- defineOperation ( global , 'setInterval' , timers . setInterval ) ;
143- defineOperation ( global , 'setTimeout' , timers . setTimeout ) ;
142+ defineOperation ( globalThis , 'clearInterval' , timers . clearInterval ) ;
143+ defineOperation ( globalThis , 'clearTimeout' , timers . clearTimeout ) ;
144+ defineOperation ( globalThis , 'setInterval' , timers . setInterval ) ;
145+ defineOperation ( globalThis , 'setTimeout' , timers . setTimeout ) ;
144146
145- defineOperation ( global , 'queueMicrotask' , queueMicrotask ) ;
147+ defineOperation ( globalThis , 'queueMicrotask' , queueMicrotask ) ;
146148
147149 // Non-standard extensions:
148- defineOperation ( global , 'clearImmediate' , timers . clearImmediate ) ;
149- defineOperation ( global , 'setImmediate' , timers . setImmediate ) ;
150+ defineOperation ( globalThis , 'clearImmediate' , timers . clearImmediate ) ;
151+ defineOperation ( globalThis , 'setImmediate' , timers . setImmediate ) ;
150152}
151153
152154// Set the per-Environment callback that will be called
@@ -280,7 +282,7 @@ function setupProcessObject() {
280282 value : 'process'
281283 } ) ;
282284 // Make process globally available to users by putting it on the global proxy
283- ObjectDefineProperty ( global , 'process' , {
285+ ObjectDefineProperty ( globalThis , 'process' , {
284286 value : process ,
285287 enumerable : false ,
286288 writable : true ,
@@ -289,7 +291,7 @@ function setupProcessObject() {
289291}
290292
291293function setupGlobalProxy ( ) {
292- ObjectDefineProperty ( global , SymbolToStringTag , {
294+ ObjectDefineProperty ( globalThis , SymbolToStringTag , {
293295 value : 'global' ,
294296 writable : false ,
295297 enumerable : false ,
@@ -306,7 +308,7 @@ function setupBuffer() {
306308 delete bufferBinding . setBufferPrototype ;
307309 delete bufferBinding . zeroFill ;
308310
309- ObjectDefineProperty ( global , 'Buffer' , {
311+ ObjectDefineProperty ( globalThis , 'Buffer' , {
310312 value : Buffer ,
311313 enumerable : false ,
312314 writable : true ,
0 commit comments