@@ -9,7 +9,12 @@ const diff = (lhs, rhs) => {
99 const r = rhs ;
1010
1111 const deletedValues = Object . keys ( l ) . reduce ( ( acc , key ) => {
12- return hasOwnProperty ( r , key ) ? acc : { ...acc , [ key ] : undefined } ;
12+ if ( ! hasOwnProperty ( r , key ) ) {
13+ acc [ key ] = undefined ;
14+ 15+ }
16+ 17+ return acc ;
1318 } , { } ) ;
1419
1520 if ( isDate ( l ) || isDate ( r ) ) {
@@ -18,15 +23,19 @@ const diff = (lhs, rhs) => {
1823 }
1924
2025 return Object . keys ( r ) . reduce ( ( acc , key ) => {
21- if ( ! hasOwnProperty ( l , key ) ) return { ...acc , [ key ] : r [ key ] } ; // return added r key
26+ if ( ! hasOwnProperty ( l , key ) ) {
27+ acc [ key ] = r [ key ] ; // return added r key
28+ return acc ;
29+ }
2230
2331 const difference = diff ( l [ key ] , r [ key ] ) ;
2432
2533 // If the difference is empty, and the lhs is an empty object or the rhs is not an empty object
2634 if ( isEmptyObject ( difference ) && ! isDate ( difference ) && ( isEmptyObject ( l [ key ] ) || ! isEmptyObject ( r [ key ] ) ) )
2735 return acc ; // return no diff
2836
29- return { ...acc , [ key ] : difference } ; // return updated key
37+ acc [ key ] = difference // return updated key
38+ return acc ; // return updated key
3039 } , deletedValues ) ;
3140} ;
3241
0 commit comments