@@ -231,20 +231,20 @@ function serializeValue(value: any): any {
231
231
return '[Array]' ;
232
232
}
233
233
234
- const normalized = normalizeValue ( value ) ;
235
- return isPrimitive ( normalized ) ? normalized : type ;
234
+ // `makeSerializable` provides a string representation of certain non-serializable values. For all others, it's a
235
+ // pass-through.
236
+ const serializable = makeSerializable ( value ) ;
237
+ return isPrimitive ( serializable ) ? serializable : type ;
236
238
}
237
239
238
240
/**
239
- * normalizeValue ()
241
+ * makeSerializable ()
240
242
*
241
- * Takes unserializable input and make it serializable friendly
243
+ * Takes unserializable input and make it serializer- friendly.
242
244
*
243
- * - translates undefined/NaN values to "[undefined]"/"[NaN]" respectively,
244
- * - serializes Error objects
245
- * - filter global objects
245
+ * Handles globals, functions, `undefined`, `NaN`, and other non-serializable values.
246
246
*/
247
- function normalizeValue < T > ( value : T , key ?: any ) : T | string {
247
+ function makeSerializable < T > ( value : T , key ?: any ) : T | string {
248
248
if ( key === 'domain' && value && typeof value === 'object' && ( value as unknown as { _events : any } ) . _events ) {
249
249
return '[Domain]' ;
250
250
}
@@ -322,10 +322,12 @@ export function walk(key: string, value: any, depth: number = +Infinity, memo: M
322
322
}
323
323
/* eslint-enable @typescript-eslint/no-unsafe-member-access */
324
324
325
- // If normalized value is a primitive, there are no branches left to walk, so bail out
326
- const normalized = normalizeValue ( value , key ) ;
327
- if ( isPrimitive ( normalized ) ) {
328
- return normalized ;
325
+ // `makeSerializable` provides a string representation of certain non-serializable values. For all others, it's a
326
+ // pass-through. If what comes back is a primitive (either because it's been stringified or because it was primitive
327
+ // all along), we're done.
328
+ const serializable = makeSerializable ( value , key ) ;
329
+ if ( isPrimitive ( serializable ) ) {
330
+ return serializable ;
329
331
}
330
332
331
333
// Create source that we will use for the next iteration. It will either be an objectified error object (`Error` type
0 commit comments