File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -92,25 +92,25 @@ function deepCopy(
9292 visitedObjects . set ( value , path ) ;
9393
9494 if ( Array . isArray ( value ) ) {
95- return value . map ( ( element , index ) =>
96- deepCopy (
97- element ,
98- `${ path } [${ index . toString ( ) } ]` ,
99- visitedObjects ,
100- replacer ,
101- ) ,
102- ) ;
95+ const copy : unknown [ ] = [ ] ;
96+
97+ for ( const [ index , element ] of value . entries ( ) ) {
98+ const newPath = `${ path } [${ index . toString ( ) } ]` ;
99+ copy [ index ] = deepCopy ( element , newPath , visitedObjects , replacer ) ;
100+ }
101+
102+ return copy ;
103103 }
104104
105105 const record = value as Record < string , unknown > ;
106+ const copy : DecycledObject = { } ;
106107
107- return Object . keys ( record ) . reduce < DecycledObject > ( ( copy , key ) => {
108- const value = record [ key ] ;
108+ for ( const key of Object . keys ( record ) ) {
109109 const newPath = `${ path } [${ JSON . stringify ( key ) } ]` ;
110+ copy [ key ] = deepCopy ( record [ key ] , newPath , visitedObjects , replacer ) ;
111+ }
110112
111- copy [ key ] = deepCopy ( value , newPath , visitedObjects , replacer ) ;
112- return copy ;
113- } , { } ) ;
113+ return copy ;
114114}
115115
116116/**
You can’t perform that action at this time.
0 commit comments