@@ -175,24 +175,19 @@ let assert;
175
175
176
176
let internalUtil = null ;
177
177
function lazyInternalUtil ( ) {
178
- if ( ! internalUtil ) {
179
- internalUtil = require ( 'internal/util' ) ;
180
- }
178
+ internalUtil ??= require ( 'internal/util' ) ;
181
179
return internalUtil ;
182
180
}
183
181
184
182
let internalUtilInspect = null ;
185
183
function lazyInternalUtilInspect ( ) {
186
- if ( ! internalUtilInspect ) {
187
- internalUtilInspect = require ( 'internal/util/inspect' ) ;
188
- }
184
+ internalUtilInspect ??= require ( 'internal/util/inspect' ) ;
189
185
return internalUtilInspect ;
190
186
}
191
187
192
188
let buffer ;
193
189
function lazyBuffer ( ) {
194
- if ( buffer === undefined )
195
- buffer = require ( 'buffer' ) . Buffer ;
190
+ buffer ??= require ( 'buffer' ) . Buffer ;
196
191
return buffer ;
197
192
}
198
193
@@ -421,7 +416,7 @@ function E(sym, val, def, ...otherClasses) {
421
416
function getMessage ( key , args , self ) {
422
417
const msg = messages . get ( key ) ;
423
418
424
- if ( assert === undefined ) assert = require ( 'internal/assert' ) ;
419
+ assert ?? = require ( 'internal/assert' ) ;
425
420
426
421
if ( typeof msg === 'function' ) {
427
422
assert (
@@ -449,19 +444,15 @@ function getMessage(key, args, self) {
449
444
let uvBinding ;
450
445
451
446
function lazyUv ( ) {
452
- if ( ! uvBinding ) {
453
- uvBinding = internalBinding ( 'uv' ) ;
454
- }
447
+ uvBinding ??= internalBinding ( 'uv' ) ;
455
448
return uvBinding ;
456
449
}
457
450
458
451
const uvUnmappedError = [ 'UNKNOWN' , 'unknown error' ] ;
459
452
460
453
function uvErrmapGet ( name ) {
461
454
uvBinding = lazyUv ( ) ;
462
- if ( ! uvBinding . errmap ) {
463
- uvBinding . errmap = uvBinding . getErrorMap ( ) ;
464
- }
455
+ uvBinding . errmap ??= uvBinding . getErrorMap ( ) ;
465
456
return MapPrototypeGet ( uvBinding . errmap , name ) ;
466
457
}
467
458
@@ -588,7 +579,7 @@ const errnoException = hideStackFrames(
588
579
// getSystemErrorName(err) to guard against invalid arguments from users.
589
580
// This can be replaced with [ code ] = errmap.get(err) when this method
590
581
// is no longer exposed to user land.
591
- if ( util === undefined ) util = require ( 'util' ) ;
582
+ util ?? = require ( 'util' ) ;
592
583
const code = util . getSystemErrorName ( err ) ;
593
584
const message = original ?
594
585
`${ syscall } ${ code } ${ original } ` : `${ syscall } ${ code } ` ;
@@ -622,7 +613,7 @@ const exceptionWithHostPort = hideStackFrames(
622
613
// getSystemErrorName(err) to guard against invalid arguments from users.
623
614
// This can be replaced with [ code ] = errmap.get(err) when this method
624
615
// is no longer exposed to user land.
625
- if ( util === undefined ) util = require ( 'util' ) ;
616
+ util ?? = require ( 'util' ) ;
626
617
const code = util . getSystemErrorName ( err ) ;
627
618
let details = '' ;
628
619
if ( port && port > 0 ) {
@@ -1238,7 +1229,7 @@ E('ERR_INVALID_ARG_TYPE',
1238
1229
} else if ( typeof actual === 'function' && actual . name ) {
1239
1230
msg += `. Received function ${ actual . name } ` ;
1240
1231
} else if ( typeof actual === 'object' ) {
1241
- if ( actual . constructor && actual . constructor . name ) {
1232
+ if ( actual . constructor ? .name ) {
1242
1233
msg += `. Received an instance of ${ actual . constructor . name } ` ;
1243
1234
} else {
1244
1235
const inspected = lazyInternalUtilInspect ( )
@@ -1332,7 +1323,7 @@ E('ERR_INVALID_RETURN_PROPERTY_VALUE', (input, name, prop, value) => {
1332
1323
} , TypeError ) ;
1333
1324
E ( 'ERR_INVALID_RETURN_VALUE' , ( input , name , value ) => {
1334
1325
let type ;
1335
- if ( value && value . constructor && value . constructor . name ) {
1326
+ if ( value ? .constructor ? .name ) {
1336
1327
type = `instance of ${ value . constructor . name } ` ;
1337
1328
} else {
1338
1329
type = `type ${ typeof value } ` ;
0 commit comments