@@ -40,6 +40,7 @@ const { internalBinding, NativeModule } = loaderExports;
40
40
const { Object, Symbol } = primordials ;
41
41
const { getOptionValue } = NativeModule . require ( 'internal/options' ) ;
42
42
const config = internalBinding ( 'config' ) ;
43
+ const { deprecate } = NativeModule . require ( 'internal/util' ) ;
43
44
44
45
setupTraceCategoryState ( ) ;
45
46
@@ -63,7 +64,11 @@ setupProcessObject();
63
64
hasUncaughtExceptionCaptureCallback ;
64
65
}
65
66
66
- setupGlobalVariables ( ) ;
67
+ setupGlobalProxy ( ) ;
68
+ setupBuffer ( ) ;
69
+
70
+ process . domain = null ;
71
+ process . _exiting = false ;
67
72
68
73
// Bootstrappers for all threads, including worker threads and main thread
69
74
const perThreadSetup = NativeModule . require ( 'internal/process/per_thread' ) ;
@@ -228,7 +233,6 @@ if (process._invalidDebug) {
228
233
'DeprecationWarning' , 'DEP0062' , undefined , true ) ;
229
234
}
230
235
231
- const { deprecate } = NativeModule . require ( 'internal/util' ) ;
232
236
// TODO(jasnell): The following have been globals since around 2012.
233
237
// That's just silly. The underlying perfctr support has been removed
234
238
// so these are now deprecated non-ops that can be removed after one
@@ -388,6 +392,8 @@ function setupProcessObject() {
388
392
const origProcProto = Object . getPrototypeOf ( process ) ;
389
393
Object . setPrototypeOf ( origProcProto , EventEmitter . prototype ) ;
390
394
EventEmitter . call ( process ) ;
395
+ // Make process globally available to users by putting it on the global proxy
396
+ global . process = process ;
391
397
}
392
398
393
399
function setupProcessStdio ( getStdout , getStdin , getStderr ) {
@@ -415,24 +421,22 @@ function setupProcessStdio(getStdout, getStdin, getStderr) {
415
421
} ;
416
422
}
417
423
418
- function setupGlobalVariables ( ) {
424
+ function setupGlobalProxy ( ) {
419
425
Object . defineProperty ( global , Symbol . toStringTag , {
420
426
value : 'global' ,
421
427
writable : false ,
422
428
enumerable : false ,
423
429
configurable : true
424
430
} ) ;
425
- global . process = process ;
426
- const util = NativeModule . require ( 'util' ) ;
427
431
428
432
function makeGetter ( name ) {
429
- return util . deprecate ( function ( ) {
433
+ return deprecate ( function ( ) {
430
434
return this ;
431
435
} , `'${ name } ' is deprecated, use 'global'` , 'DEP0016' ) ;
432
436
}
433
437
434
438
function makeSetter ( name ) {
435
- return util . deprecate ( function ( value ) {
439
+ return deprecate ( function ( value ) {
436
440
Object . defineProperty ( this , name , {
437
441
configurable : true ,
438
442
writable : true ,
@@ -454,7 +458,9 @@ function setupGlobalVariables() {
454
458
set : makeSetter ( 'root' )
455
459
}
456
460
} ) ;
461
+ }
457
462
463
+ function setupBuffer ( ) {
458
464
const { Buffer } = NativeModule . require ( 'buffer' ) ;
459
465
const bufferBinding = internalBinding ( 'buffer' ) ;
460
466
@@ -464,8 +470,6 @@ function setupGlobalVariables() {
464
470
delete bufferBinding . zeroFill ;
465
471
466
472
global . Buffer = Buffer ;
467
- process . domain = null ;
468
- process . _exiting = false ;
469
473
}
470
474
471
475
function setupGlobalTimeouts ( ) {
0 commit comments