@@ -175,24 +175,19 @@ let assert;
175175
176176let internalUtil = null ;
177177function lazyInternalUtil ( ) {
178- if ( ! internalUtil ) {
179- internalUtil = require ( 'internal/util' ) ;
180- }
178+ internalUtil ??= require ( 'internal/util' ) ;
181179 return internalUtil ;
182180}
183181
184182let internalUtilInspect = null ;
185183function lazyInternalUtilInspect ( ) {
186- if ( ! internalUtilInspect ) {
187- internalUtilInspect = require ( 'internal/util/inspect' ) ;
188- }
184+ internalUtilInspect ??= require ( 'internal/util/inspect' ) ;
189185 return internalUtilInspect ;
190186}
191187
192188let buffer ;
193189function lazyBuffer ( ) {
194- if ( buffer === undefined )
195- buffer = require ( 'buffer' ) . Buffer ;
190+ buffer ??= require ( 'buffer' ) . Buffer ;
196191 return buffer ;
197192}
198193
@@ -411,7 +406,7 @@ function E(sym, val, def, ...otherClasses) {
411406function getMessage ( key , args , self ) {
412407 const msg = messages . get ( key ) ;
413408
414- if ( assert === undefined ) assert = require ( 'internal/assert' ) ;
409+ assert ?? = require ( 'internal/assert' ) ;
415410
416411 if ( typeof msg === 'function' ) {
417412 assert (
@@ -439,19 +434,15 @@ function getMessage(key, args, self) {
439434let uvBinding ;
440435
441436function lazyUv ( ) {
442- if ( ! uvBinding ) {
443- uvBinding = internalBinding ( 'uv' ) ;
444- }
437+ uvBinding ??= internalBinding ( 'uv' ) ;
445438 return uvBinding ;
446439}
447440
448441const uvUnmappedError = [ 'UNKNOWN' , 'unknown error' ] ;
449442
450443function uvErrmapGet ( name ) {
451444 uvBinding = lazyUv ( ) ;
452- if ( ! uvBinding . errmap ) {
453- uvBinding . errmap = uvBinding . getErrorMap ( ) ;
454- }
445+ uvBinding . errmap ??= uvBinding . getErrorMap ( ) ;
455446 return MapPrototypeGet ( uvBinding . errmap , name ) ;
456447}
457448
@@ -578,7 +569,7 @@ const errnoException = hideStackFrames(
578569 // getSystemErrorName(err) to guard against invalid arguments from users.
579570 // This can be replaced with [ code ] = errmap.get(err) when this method
580571 // is no longer exposed to user land.
581- if ( util === undefined ) util = require ( 'util' ) ;
572+ util ?? = require ( 'util' ) ;
582573 const code = util . getSystemErrorName ( err ) ;
583574 const message = original ?
584575 `${ syscall } ${ code } ${ original } ` : `${ syscall } ${ code } ` ;
@@ -612,7 +603,7 @@ const exceptionWithHostPort = hideStackFrames(
612603 // getSystemErrorName(err) to guard against invalid arguments from users.
613604 // This can be replaced with [ code ] = errmap.get(err) when this method
614605 // is no longer exposed to user land.
615- if ( util === undefined ) util = require ( 'util' ) ;
606+ util ?? = require ( 'util' ) ;
616607 const code = util . getSystemErrorName ( err ) ;
617608 let details = '' ;
618609 if ( port && port > 0 ) {
@@ -1224,7 +1215,7 @@ E('ERR_INVALID_ARG_TYPE',
12241215 } else if ( typeof actual === 'function' && actual . name ) {
12251216 msg += `. Received function ${ actual . name } ` ;
12261217 } else if ( typeof actual === 'object' ) {
1227- if ( actual . constructor && actual . constructor . name ) {
1218+ if ( actual . constructor ? .name ) {
12281219 msg += `. Received an instance of ${ actual . constructor . name } ` ;
12291220 } else {
12301221 const inspected = lazyInternalUtilInspect ( )
@@ -1320,7 +1311,7 @@ E('ERR_INVALID_RETURN_PROPERTY_VALUE', (input, name, prop, value) => {
13201311} , TypeError ) ;
13211312E ( 'ERR_INVALID_RETURN_VALUE' , ( input , name , value ) => {
13221313 let type ;
1323- if ( value && value . constructor && value . constructor . name ) {
1314+ if ( value ? .constructor ? .name ) {
13241315 type = `instance of ${ value . constructor . name } ` ;
13251316 } else {
13261317 type = `type ${ typeof value } ` ;
0 commit comments