@@ -50,9 +50,9 @@ internals.atUnnamedRx = /^\s*at (?:async )?(.+)\:(\d+)\:(\d+)\)?$/;
50
50
51
51
exports . thrownAt = function ( error ) {
52
52
53
- error = error || new Error ( ) ;
53
+ error = error ?? new Error ( ) ;
54
54
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 ] ?? '' ;
56
56
const at = frame . match ( frame . includes ( '(' ) ? internals . atNamedRx : internals . atUnnamedRx ) ;
57
57
return Array . isArray ( at ) ? {
58
58
filename : at [ 1 ] ,
@@ -83,7 +83,7 @@ exports.expect = function (value, prefix) {
83
83
internals . Assertion = function ( ref , prefix , location , at ) {
84
84
85
85
this . _ref = ref ;
86
- this . _prefix = prefix || '' ;
86
+ this . _prefix = prefix ?? '' ;
87
87
this . _location = location ;
88
88
this . _at = at ;
89
89
this . _flags = { } ;
@@ -135,7 +135,7 @@ internals.Assertion.prototype.assert = function (result, verb, actual, expected)
135
135
Error . captureStackTrace ( error , this . assert ) ;
136
136
error . actual = actual ;
137
137
error . expected = expected ;
138
- error . at = exports . thrownAt ( error ) || this . _at ;
138
+ error . at = exports . thrownAt ( error ) ?? this . _at ;
139
139
throw error ;
140
140
} ;
141
141
@@ -193,7 +193,7 @@ internals.addMethod = function (names, fn) {
193
193
internals . addMethod ( 'error' , function ( ...args /* type, message */ ) {
194
194
195
195
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 ] ;
197
197
const message = typeof lastArg === 'string' || lastArg instanceof RegExp ? lastArg : null ;
198
198
const err = this . _ref ;
199
199
@@ -296,7 +296,7 @@ internals.addMethod('length', internals.length);
296
296
297
297
internals . equal = function ( value , options ) {
298
298
299
- options = options || { } ;
299
+ options = options ?? { } ;
300
300
const settings = Hoek . applyToDefaults ( { prototype : exports . settings . comparePrototypes , deepFunction : true } , options ) ;
301
301
302
302
const compare = this . _flags . shallow ? ( a , b ) => a === b
@@ -397,7 +397,7 @@ internals.throw = function (...args /* type, message */) {
397
397
internals . assert ( this , ! this . _flags . not || ! args . length , 'Cannot specify arguments when expecting not to throw' ) ;
398
398
399
399
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 ] ;
401
401
const message = typeof lastArg === 'string' || lastArg instanceof RegExp ? lastArg : null ;
402
402
403
403
let thrown = false ;
@@ -413,7 +413,7 @@ internals.throw = function (...args /* type, message */) {
413
413
}
414
414
415
415
if ( message !== null ) {
416
- const error = err . message || '' ;
416
+ const error = err . message ?? '' ;
417
417
this . assert ( typeof message === 'string' ? error === message : error . match ( message ) , 'throw an error with specified message' , error , message ) ;
418
418
}
419
419
@@ -433,7 +433,7 @@ internals.reject = async function (...args/* type, message */) {
433
433
internals . assert ( this , internals . isPromise ( this . _ref ) , 'Can only assert reject on promises' ) ;
434
434
435
435
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 ] ;
437
437
const message = typeof lastArg === 'string' || lastArg instanceof RegExp ? lastArg : null ;
438
438
439
439
let thrown = null ;
@@ -456,7 +456,7 @@ internals.reject = async function (...args/* type, message */) {
456
456
}
457
457
458
458
if ( message !== null ) {
459
- const error = thrown . message || '' ;
459
+ const error = thrown . message ?? '' ;
460
460
this . assert ( typeof message === 'string' ? error === message : error . match ( message ) , 'reject with an error with specified message' , error , message ) ;
461
461
}
462
462
@@ -479,7 +479,7 @@ internals.addMethod(['reject', 'rejects'], internals.reject);
479
479
480
480
internals . isPromise = function ( promise ) {
481
481
482
- return promise && typeof promise . then === 'function' ;
482
+ return typeof promise ? .then === 'function' ;
483
483
} ;
484
484
485
485
0 commit comments