@@ -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
@@ -411,7 +406,7 @@ function E(sym, val, def, ...otherClasses) {
411
406
function getMessage ( key , args , self ) {
412
407
const msg = messages . get ( key ) ;
413
408
414
- if ( assert === undefined ) assert = require ( 'internal/assert' ) ;
409
+ assert ?? = require ( 'internal/assert' ) ;
415
410
416
411
if ( typeof msg === 'function' ) {
417
412
assert (
@@ -439,19 +434,15 @@ function getMessage(key, args, self) {
439
434
let uvBinding ;
440
435
441
436
function lazyUv ( ) {
442
- if ( ! uvBinding ) {
443
- uvBinding = internalBinding ( 'uv' ) ;
444
- }
437
+ uvBinding ??= internalBinding ( 'uv' ) ;
445
438
return uvBinding ;
446
439
}
447
440
448
441
const uvUnmappedError = [ 'UNKNOWN' , 'unknown error' ] ;
449
442
450
443
function uvErrmapGet ( name ) {
451
444
uvBinding = lazyUv ( ) ;
452
- if ( ! uvBinding . errmap ) {
453
- uvBinding . errmap = uvBinding . getErrorMap ( ) ;
454
- }
445
+ uvBinding . errmap ??= uvBinding . getErrorMap ( ) ;
455
446
return MapPrototypeGet ( uvBinding . errmap , name ) ;
456
447
}
457
448
@@ -578,7 +569,7 @@ const errnoException = hideStackFrames(
578
569
// getSystemErrorName(err) to guard against invalid arguments from users.
579
570
// This can be replaced with [ code ] = errmap.get(err) when this method
580
571
// is no longer exposed to user land.
581
- if ( util === undefined ) util = require ( 'util' ) ;
572
+ util ?? = require ( 'util' ) ;
582
573
const code = util . getSystemErrorName ( err ) ;
583
574
const message = original ?
584
575
`${ syscall } ${ code } ${ original } ` : `${ syscall } ${ code } ` ;
@@ -612,7 +603,7 @@ const exceptionWithHostPort = hideStackFrames(
612
603
// getSystemErrorName(err) to guard against invalid arguments from users.
613
604
// This can be replaced with [ code ] = errmap.get(err) when this method
614
605
// is no longer exposed to user land.
615
- if ( util === undefined ) util = require ( 'util' ) ;
606
+ util ?? = require ( 'util' ) ;
616
607
const code = util . getSystemErrorName ( err ) ;
617
608
let details = '' ;
618
609
if ( port && port > 0 ) {
@@ -1224,7 +1215,7 @@ E('ERR_INVALID_ARG_TYPE',
1224
1215
} else if ( typeof actual === 'function' && actual . name ) {
1225
1216
msg += `. Received function ${ actual . name } ` ;
1226
1217
} else if ( typeof actual === 'object' ) {
1227
- if ( actual . constructor && actual . constructor . name ) {
1218
+ if ( actual . constructor ? .name ) {
1228
1219
msg += `. Received an instance of ${ actual . constructor . name } ` ;
1229
1220
} else {
1230
1221
const inspected = lazyInternalUtilInspect ( )
@@ -1320,7 +1311,7 @@ E('ERR_INVALID_RETURN_PROPERTY_VALUE', (input, name, prop, value) => {
1320
1311
} , TypeError ) ;
1321
1312
E ( 'ERR_INVALID_RETURN_VALUE' , ( input , name , value ) => {
1322
1313
let type ;
1323
- if ( value && value . constructor && value . constructor . name ) {
1314
+ if ( value ? .constructor ? .name ) {
1324
1315
type = `instance of ${ value . constructor . name } ` ;
1325
1316
} else {
1326
1317
type = `type ${ typeof value } ` ;
0 commit comments