Skip to content

Commit 8583aa4

Browse files
committed
split out value and move typecast for readability
1 parent e3679a2 commit 8583aa4

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

packages/utils/src/object.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ export function walk(key: string, value: any, depth: number = +Infinity, memo: M
335335
const source = getWalkSource(value);
336336

337337
// Create an accumulator that will act as a parent for all future itterations of that branch
338-
const acc = Array.isArray(value) ? [] : {};
338+
const acc: { [key: string]: any } = Array.isArray(value) ? [] : {};
339339

340340
// If we already walked that branch, bail out, as it's circular reference
341341
if (memo[0](value)) {
@@ -349,7 +349,8 @@ export function walk(key: string, value: any, depth: number = +Infinity, memo: M
349349
continue;
350350
}
351351
// Recursively walk through all the child nodes
352-
(acc as { [key: string]: any })[innerKey] = walk(innerKey, source[innerKey], depth - 1, memo);
352+
const innerValue: any = source[innerKey];
353+
acc[innerKey] = walk(innerKey, innerValue, depth - 1, memo);
353354
}
354355

355356
// Once walked through all the branches, remove the parent from memo storage

0 commit comments

Comments
 (0)