File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -2,22 +2,22 @@ const isObject = o => o != null && typeof o === 'object';
22const isEmpty = o => Object . keys ( o ) . length === 0 ;
33
44const diff = ( lhs , rhs ) => {
5- if ( lhs === rhs ) return { } ;
5+ if ( lhs === rhs ) return { } ; // equal return no diff
66
7- if ( ! isObject ( lhs ) || ! isObject ( rhs ) ) return rhs ;
7+ if ( ! isObject ( lhs ) || ! isObject ( rhs ) ) return rhs ; // return updated rhs
88
99 const deletedValues = Object . keys ( lhs ) . reduce ( ( acc , key ) => {
1010 return rhs . hasOwnProperty ( key ) ? acc : { ...acc , [ key ] : undefined } ;
1111 } , { } ) ;
1212
1313 return Object . keys ( rhs ) . reduce ( ( acc , key ) => {
14- if ( ! lhs . hasOwnProperty ( key ) ) return { ...acc , [ key ] : rhs [ key ] } ;
14+ if ( ! lhs . hasOwnProperty ( key ) ) return { ...acc , [ key ] : rhs [ key ] } ; // return added rhs key
1515
1616 const difference = diff ( lhs [ key ] , rhs [ key ] ) ;
1717
18- if ( isObject ( difference ) && isEmpty ( difference ) ) return acc ;
18+ if ( isObject ( difference ) && isEmpty ( difference ) ) return acc ; // return no diff
1919
20- return { ...acc , [ key ] : difference } ;
20+ return { ...acc , [ key ] : difference } ; // return updated key
2121 } , deletedValues ) ;
2222} ;
2323
You can’t perform that action at this time.
0 commit comments