@@ -30,7 +30,7 @@ String.prototype.sample = function (value: unknown): string {
30
30
/* eslint-disable unicorn/switch-case-braces */
31
31
case "bigint" : return `${ this } : ${ value } n` ;
32
32
case "boolean" : return `${ this } : ${ value } ` ;
33
- case "function" : return `${ this } : ${ value . name } () ` ;
33
+ case "function" : return `${ this } : ${ value . toString ( ) } ` ;
34
34
case "number" : return `${ this } : ${ value } ` ;
35
35
case "object" : {
36
36
const stringified = value ? value . toString ( ) : `null` ;
@@ -67,6 +67,7 @@ function getFormattedPrimitiveValue(value: unknown): string {
67
67
/* eslint-disable unicorn/switch-case-braces */
68
68
case "bigint" : return `${ value } n` ;
69
69
case "boolean" : return `${ value } ` ;
70
+ case "function" : return `${ value . toString ( ) } ` ;
70
71
case "number" : return `${ value } ` ;
71
72
case "string" : return `"${ value } "` ;
72
73
case "symbol" : return `"${ value . toString ( ) } "` ;
@@ -97,7 +98,15 @@ function stringifyValue(value: unknown, valueType: string): string | undefined {
97
98
}
98
99
99
100
function jsonReplacer ( _key : string , value : unknown ) {
100
- return typeof value === "bigint" ? `${ value . toString ( ) } n` : value ;
101
+ /* prettier-ignore */
102
+ switch ( typeof value ) {
103
+ /* eslint-disable unicorn/switch-case-braces */
104
+ case "bigint" : return `${ value . toString ( ) } n` ;
105
+ case "function" : return value . toString ( ) ;
106
+ case "undefined" : return `undefined` ;
107
+ default : return value ;
108
+ /* eslint-enable unicorn/switch-case-braces */
109
+ }
101
110
}
102
111
103
112
function getStringifiedAndTruncatedArray ( array : Array < unknown > ) : string {
0 commit comments