@@ -50,9 +50,9 @@ internals.atUnnamedRx = /^\s*at (?:async )?(.+)\:(\d+)\:(\d+)\)?$/;
5050
5151exports . thrownAt = function ( error ) {
5252
53- error = error || new Error ( ) ;
53+ error = error ?? new Error ( ) ;
5454 const stack = typeof error . stack === 'string' ? error . stack : '' ;
55- const frame = stack . replace ( error . toString ( ) , '' ) . split ( '\n' ) . slice ( 1 ) . filter ( internals . filterLocal ) [ 0 ] || '' ;
55+ const frame = stack . replace ( error . toString ( ) , '' ) . split ( '\n' ) . slice ( 1 ) . filter ( internals . filterLocal ) [ 0 ] ?? '' ;
5656 const at = frame . match ( frame . includes ( '(' ) ? internals . atNamedRx : internals . atUnnamedRx ) ;
5757 return Array . isArray ( at ) ? {
5858 filename : at [ 1 ] ,
@@ -83,7 +83,7 @@ exports.expect = function (value, prefix) {
8383internals . Assertion = function ( ref , prefix , location , at ) {
8484
8585 this . _ref = ref ;
86- this . _prefix = prefix || '' ;
86+ this . _prefix = prefix ?? '' ;
8787 this . _location = location ;
8888 this . _at = at ;
8989 this . _flags = { } ;
@@ -135,7 +135,7 @@ internals.Assertion.prototype.assert = function (result, verb, actual, expected)
135135 Error . captureStackTrace ( error , this . assert ) ;
136136 error . actual = actual ;
137137 error . expected = expected ;
138- error . at = exports . thrownAt ( error ) || this . _at ;
138+ error . at = exports . thrownAt ( error ) ?? this . _at ;
139139 throw error ;
140140} ;
141141
@@ -193,7 +193,7 @@ internals.addMethod = function (names, fn) {
193193internals . addMethod ( 'error' , function ( ...args /* type, message */ ) {
194194
195195 const type = args . length && typeof args [ 0 ] !== 'string' && ! ( args [ 0 ] instanceof RegExp ) ? args [ 0 ] : Error ;
196- const lastArg = args [ 1 ] || args [ 0 ] ;
196+ const lastArg = args [ 1 ] ?? args [ 0 ] ;
197197 const message = typeof lastArg === 'string' || lastArg instanceof RegExp ? lastArg : null ;
198198 const err = this . _ref ;
199199
@@ -296,7 +296,7 @@ internals.addMethod('length', internals.length);
296296
297297internals . equal = function ( value , options ) {
298298
299- options = options || { } ;
299+ options = options ?? { } ;
300300 const settings = Hoek . applyToDefaults ( { prototype : exports . settings . comparePrototypes , deepFunction : true } , options ) ;
301301
302302 const compare = this . _flags . shallow ? ( a , b ) => a === b
@@ -397,7 +397,7 @@ internals.throw = function (...args /* type, message */) {
397397 internals . assert ( this , ! this . _flags . not || ! args . length , 'Cannot specify arguments when expecting not to throw' ) ;
398398
399399 const type = args . length && typeof args [ 0 ] !== 'string' && ! ( args [ 0 ] instanceof RegExp ) ? args [ 0 ] : null ;
400- const lastArg = args [ 1 ] || args [ 0 ] ;
400+ const lastArg = args [ 1 ] ?? args [ 0 ] ;
401401 const message = typeof lastArg === 'string' || lastArg instanceof RegExp ? lastArg : null ;
402402
403403 let thrown = false ;
@@ -413,7 +413,7 @@ internals.throw = function (...args /* type, message */) {
413413 }
414414
415415 if ( message !== null ) {
416- const error = err . message || '' ;
416+ const error = err . message ?? '' ;
417417 this . assert ( typeof message === 'string' ? error === message : error . match ( message ) , 'throw an error with specified message' , error , message ) ;
418418 }
419419
@@ -433,7 +433,7 @@ internals.reject = async function (...args/* type, message */) {
433433 internals . assert ( this , internals . isPromise ( this . _ref ) , 'Can only assert reject on promises' ) ;
434434
435435 const type = args . length && typeof args [ 0 ] !== 'string' && ! ( args [ 0 ] instanceof RegExp ) ? args [ 0 ] : null ;
436- const lastArg = args [ 1 ] || args [ 0 ] ;
436+ const lastArg = args [ 1 ] ?? args [ 0 ] ;
437437 const message = typeof lastArg === 'string' || lastArg instanceof RegExp ? lastArg : null ;
438438
439439 let thrown = null ;
@@ -456,7 +456,7 @@ internals.reject = async function (...args/* type, message */) {
456456 }
457457
458458 if ( message !== null ) {
459- const error = thrown . message || '' ;
459+ const error = thrown . message ?? '' ;
460460 this . assert ( typeof message === 'string' ? error === message : error . match ( message ) , 'reject with an error with specified message' , error , message ) ;
461461 }
462462
@@ -479,7 +479,7 @@ internals.addMethod(['reject', 'rejects'], internals.reject);
479479
480480internals . isPromise = function ( promise ) {
481481
482- return promise && typeof promise . then === 'function' ;
482+ return typeof promise ? .then === 'function' ;
483483} ;
484484
485485
0 commit comments