@@ -48,6 +48,7 @@ const {
4848 String,
4949 StringPrototypeEndsWith,
5050 StringPrototypeIncludes,
51+ StringPrototypeIndexOf,
5152 StringPrototypeSlice,
5253 StringPrototypeSplit,
5354 StringPrototypeStartsWith,
@@ -874,23 +875,53 @@ const genericNodeError = hideStackFrames(function genericNodeError(message, erro
874875 * @returns {string }
875876 */
876877function determineSpecificType ( value ) {
877- if ( value == null ) {
878- return '' + value ;
878+ if ( value === null ) {
879+ return 'null' ;
880+ } else if ( value === undefined ) {
881+ return 'undefined' ;
879882 }
880- if ( typeof value === 'function' && value . name ) {
881- return `function ${ value . name } ` ;
882- }
883- if ( typeof value === 'object' ) {
884- if ( value . constructor ?. name ) {
885- return `an instance of ${ value . constructor . name } ` ;
886- }
887- return `${ lazyInternalUtilInspect ( ) . inspect ( value , { depth : - 1 } ) } ` ;
888- }
889- let inspected = lazyInternalUtilInspect ( )
890- . inspect ( value , { colors : false } ) ;
891- if ( inspected . length > 28 ) { inspected = `${ StringPrototypeSlice ( inspected , 0 , 25 ) } ...` ; }
892883
893- return `type ${ typeof value } (${ inspected } )` ;
884+ const type = typeof value ;
885+
886+ switch ( type ) {
887+ case 'bigint' :
888+ return `type bigint (${ value } n)` ;
889+ case 'number' :
890+ if ( value === 0 ) {
891+ return 1 / value === - Infinity ? 'type number (-0)' : 'type number (0)' ;
892+ } else if ( value !== value ) { // eslint-disable-line no-self-compare
893+ return 'type number (NaN)' ;
894+ } else if ( value === Infinity ) {
895+ return 'type number (Infinity)' ;
896+ } else if ( value === - Infinity ) {
897+ return 'type number (-Infinity)' ;
898+ }
899+ return `type number (${ value } )` ;
900+ case 'boolean' :
901+ return value ? 'type boolean (true)' : 'type boolean (false)' ;
902+ case 'symbol' :
903+ return `type symbol (${ String ( value ) } )` ;
904+ case 'function' :
905+ return `function ${ value . name } ` ;
906+ case 'object' :
907+ if ( value . constructor && 'name' in value . constructor ) {
908+ return `an instance of ${ value . constructor . name } ` ;
909+ }
910+ return `${ lazyInternalUtilInspect ( ) . inspect ( value , { depth : - 1 } ) } ` ;
911+ case 'string' :
912+ value . length > 28 && ( value = `${ StringPrototypeSlice ( value , 0 , 25 ) } ...` ) ;
913+ if ( StringPrototypeIndexOf ( value , "'" ) === - 1 ) {
914+ return `type string ('${ value } ')` ;
915+ }
916+ return `type string (${ JSONStringify ( value ) } )` ;
917+ default :
918+ value = lazyInternalUtilInspect ( ) . inspect ( value , { colors : false } ) ;
919+ if ( value . length > 28 ) {
920+ value = `${ StringPrototypeSlice ( value , 0 , 25 ) } ...` ;
921+ }
922+
923+ return `type ${ type } (${ value } )` ;
924+ }
894925}
895926
896927/**
0 commit comments