Skip to content

Commit 2533542

Browse files
committed
chore(logger): changes due to lint
1 parent cf2cb4d commit 2533542

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/logger/index.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,17 @@ function removeCircular(obj: any, refs: any[] = []): any {
6767
// Add the current object to the recursion stack.
6868
refs.push(obj);
6969

70-
const returnObj: any = Array.isArray(obj) ? [] : {};
71-
for (const key in obj) {
72-
returnObj[key] = removeCircular(obj[key], refs);
70+
// If the object is an array, run circular check on each element.
71+
let returnObj: any;
72+
if (Array.isArray(obj)) {
73+
returnObj = obj.map((item) => removeCircular(item, refs));
74+
}
75+
// If the object is a Map, run circular check on each key and value.
76+
else {
77+
returnObj = {};
78+
for (const key of Object.keys(obj)) {
79+
returnObj[key] = removeCircular(obj[key], refs);
80+
}
7381
}
7482

7583
// Remove the current object from the stack once its properties are processed.

0 commit comments

Comments
 (0)