Skip to content

Commit d510466

Browse files
committed
stop using JSON parse and stringify in normalization
1 parent 0b2221d commit d510466

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/utils/src/object.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,8 @@ export function walk(key: string, value: any, depth: number = +Infinity, memo: M
372372
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
373373
export function normalize(input: any, depth?: number): any {
374374
try {
375-
return JSON.parse(JSON.stringify(input, (key: string, value: any) => walk(key, value, depth)));
375+
// since we're at the outermost level, there is no key
376+
return walk('', input, depth);
376377
} catch (_oO) {
377378
return '**non-serializable**';
378379
}

0 commit comments

Comments
 (0)