@@ -45,6 +45,7 @@ const {
45
45
ObjectGetPrototypeOf,
46
46
ObjectSetPrototypeOf,
47
47
SymbolToStringTag,
48
+ globalThis,
48
49
} = primordials ;
49
50
const config = internalBinding ( 'config' ) ;
50
51
const { deprecate } = require ( 'internal/util' ) ;
@@ -119,34 +120,35 @@ if (!config.noBrowserGlobals) {
119
120
// Override global console from the one provided by the VM
120
121
// to the one implemented by Node.js
121
122
// https://console.spec.whatwg.org/#console-namespace
122
- exposeNamespace ( global , 'console' , createGlobalConsole ( global . console ) ) ;
123
+ exposeNamespace ( globalThis , 'console' ,
124
+ createGlobalConsole ( globalThis . console ) ) ;
123
125
124
126
const { URL , URLSearchParams } = require ( 'internal/url' ) ;
125
127
// https://url.spec.whatwg.org/#url
126
- exposeInterface ( global , 'URL' , URL ) ;
128
+ exposeInterface ( globalThis , 'URL' , URL ) ;
127
129
// https://url.spec.whatwg.org/#urlsearchparams
128
- exposeInterface ( global , 'URLSearchParams' , URLSearchParams ) ;
130
+ exposeInterface ( globalThis , 'URLSearchParams' , URLSearchParams ) ;
129
131
130
132
const {
131
133
TextEncoder, TextDecoder
132
134
} = require ( 'internal/encoding' ) ;
133
135
// https://encoding.spec.whatwg.org/#textencoder
134
- exposeInterface ( global , 'TextEncoder' , TextEncoder ) ;
136
+ exposeInterface ( globalThis , 'TextEncoder' , TextEncoder ) ;
135
137
// https://encoding.spec.whatwg.org/#textdecoder
136
- exposeInterface ( global , 'TextDecoder' , TextDecoder ) ;
138
+ exposeInterface ( globalThis , 'TextDecoder' , TextDecoder ) ;
137
139
138
140
// https://html.spec.whatwg.org/multipage/webappapis.html#windoworworkerglobalscope
139
141
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 ) ;
144
146
145
- defineOperation ( global , 'queueMicrotask' , queueMicrotask ) ;
147
+ defineOperation ( globalThis , 'queueMicrotask' , queueMicrotask ) ;
146
148
147
149
// 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 ) ;
150
152
}
151
153
152
154
// Set the per-Environment callback that will be called
@@ -280,7 +282,7 @@ function setupProcessObject() {
280
282
value : 'process'
281
283
} ) ;
282
284
// Make process globally available to users by putting it on the global proxy
283
- ObjectDefineProperty ( global , 'process' , {
285
+ ObjectDefineProperty ( globalThis , 'process' , {
284
286
value : process ,
285
287
enumerable : false ,
286
288
writable : true ,
@@ -289,7 +291,7 @@ function setupProcessObject() {
289
291
}
290
292
291
293
function setupGlobalProxy ( ) {
292
- ObjectDefineProperty ( global , SymbolToStringTag , {
294
+ ObjectDefineProperty ( globalThis , SymbolToStringTag , {
293
295
value : 'global' ,
294
296
writable : false ,
295
297
enumerable : false ,
@@ -306,7 +308,7 @@ function setupBuffer() {
306
308
delete bufferBinding . setBufferPrototype ;
307
309
delete bufferBinding . zeroFill ;
308
310
309
- ObjectDefineProperty ( global , 'Buffer' , {
311
+ ObjectDefineProperty ( globalThis , 'Buffer' , {
310
312
value : Buffer ,
311
313
enumerable : false ,
312
314
writable : true ,
0 commit comments