@@ -345,11 +345,11 @@ class Assert {
345
345
// Return a rejected promise if `promiseFn` throws synchronously.
346
346
resultPromise = promiseFn ( ) ;
347
347
// Fail in case no promise is returned.
348
- if ( ! checkIsPromise ( resultPromise ) ) {
348
+ if ( ! this . # checkIsPromise( resultPromise ) ) {
349
349
throw new ERR_INVALID_RETURN_VALUE ( 'instance of Promise' ,
350
350
'promiseFn' , resultPromise ) ;
351
351
}
352
- } else if ( checkIsPromise ( promiseFn ) ) {
352
+ } else if ( this . # checkIsPromise( promiseFn ) ) {
353
353
resultPromise = promiseFn ;
354
354
} else {
355
355
throw new ERR_INVALID_ARG_TYPE (
@@ -374,6 +374,16 @@ class Assert {
374
374
return NO_EXCEPTION_SENTINEL ;
375
375
}
376
376
377
+ #checkIsPromise( obj ) {
378
+ // Accept native ES6 promises and promises that are implemented in a similar
379
+ // way. Do not accept thenables that use a function as `obj` and that have no
380
+ // `catch` handler.
381
+ return isPromise ( obj ) ||
382
+ ( obj !== null && typeof obj === 'object' &&
383
+ typeof obj . then === 'function' &&
384
+ typeof obj . catch === 'function' ) ;
385
+ }
386
+
377
387
/**
378
388
* Pure assertion tests whether a value is truthy, as determined
379
389
* by !!value.
@@ -808,16 +818,6 @@ class Comparison {
808
818
}
809
819
}
810
820
811
- function checkIsPromise ( obj ) {
812
- // Accept native ES6 promises and promises that are implemented in a similar
813
- // way. Do not accept thenables that use a function as `obj` and that have no
814
- // `catch` handler.
815
- return isPromise ( obj ) ||
816
- ( obj !== null && typeof obj === 'object' &&
817
- typeof obj . then === 'function' &&
818
- typeof obj . catch === 'function' ) ;
819
- }
820
-
821
821
function hasMatchingError ( actual , expected ) {
822
822
if ( typeof expected !== 'function' ) {
823
823
if ( isRegExp ( expected ) ) {
0 commit comments