File tree Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Expand file tree Collapse file tree 1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -14,18 +14,20 @@ const formatJson = (data, parentPath = '') => {
1414 condition,
1515 } ;
1616
17+ // Используем деструктуризацию и условное добавление свойств
1718 if ( keyOld !== undefined || newValue !== undefined ) {
18- resultObj . oldValue = keyOld ;
19- resultObj . newValue = newValue ;
20- } else {
21- resultObj . value = value ;
19+ return {
20+ ...resultObj ,
21+ oldValue : keyOld ,
22+ newValue,
23+ ...( children && { children : iner ( children , currentPath ) } ) ,
24+ } ;
2225 }
23-
24- if ( children ) {
25- resultObj . children = iner ( children , currentPath ) ;
26- }
27-
28- return resultObj ;
26+ return {
27+ ...resultObj ,
28+ value,
29+ ...( children && { children : iner ( children , currentPath ) } ) ,
30+ } ;
2931 } ) ;
3032
3133 const result = iner ( data , parentPath ) ;
You can’t perform that action at this time.
0 commit comments