Skip to content

Commit d1c5314

Browse files
test(helpers): use template strings and arrow function in decycle
1 parent ef82d4c commit d1c5314

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

__tests__/helpers/decycle.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ function deepCopy(
100100

101101
if (Array.isArray(value)) {
102102
copy = [];
103-
(value as unknown[]).forEach(function (element: unknown, index: number) {
103+
(value as unknown[]).forEach((element: unknown, index: number) => {
104104
(copy as unknown[])[index] = deepCopy(
105105
element,
106-
path + '[' + String(index) + ']',
106+
`${path}[${index.toString()}]`,
107107
visitedObjects,
108108
replacer,
109109
);
@@ -115,13 +115,15 @@ function deepCopy(
115115
) {
116116
(copy as DecycledObject)[key] = deepCopy(
117117
(value as Record<string, unknown>)[key],
118-
path + '[' + JSON.stringify(key) + ']',
118+
`${path}[${JSON.stringify(key)}]`,
119119
visitedObjects,
120120
replacer,
121121
);
122122
});
123123
}
124+
124125
return copy;
125126
}
127+
126128
return value;
127129
}

0 commit comments

Comments
 (0)