File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments