@@ -5,33 +5,30 @@ const diff = (lhs, rhs) => {
5
5
6
6
if ( ! isObject ( lhs ) || ! isObject ( rhs ) ) return rhs ; // return updated rhs
7
7
8
- const l = lhs ;
9
- const r = rhs ;
10
-
11
- const deletedValues = Object . keys ( l ) . reduce ( ( acc , key ) => {
12
- if ( ! hasOwnProperty ( r , key ) ) {
8
+ const deletedValues = Object . keys ( lhs ) . reduce ( ( acc , key ) => {
9
+ if ( ! hasOwnProperty ( rhs , key ) ) {
13
10
acc [ key ] = undefined ;
14
11
15
12
}
16
13
17
14
return acc ;
18
15
} , makeObjectWithoutPrototype ( ) ) ;
19
16
20
- if ( isDate ( l ) || isDate ( r ) ) {
21
- if ( l . valueOf ( ) == r . valueOf ( ) ) return { } ;
22
- return r ;
17
+ if ( isDate ( lhs ) || isDate ( rhs ) ) {
18
+ if ( lhs . valueOf ( ) == rhs . valueOf ( ) ) return { } ;
19
+ return rhs ;
23
20
}
24
21
25
- return Object . keys ( r ) . reduce ( ( acc , key ) => {
26
- if ( ! hasOwnProperty ( l , key ) ) {
27
- acc [ key ] = r [ key ] ; // return added r key
22
+ return Object . keys ( rhs ) . reduce ( ( acc , key ) => {
23
+ if ( ! hasOwnProperty ( lhs , key ) ) {
24
+ acc [ key ] = rhs [ key ] ; // return added r key
28
25
return acc ;
29
26
}
30
27
31
- const difference = diff ( l [ key ] , r [ key ] ) ;
28
+ const difference = diff ( lhs [ key ] , rhs [ key ] ) ;
32
29
33
30
// If the difference is empty, and the lhs is an empty object or the rhs is not an empty object
34
- if ( isEmptyObject ( difference ) && ! isDate ( difference ) && ( isEmptyObject ( l [ key ] ) || ! isEmptyObject ( r [ key ] ) ) )
31
+ if ( isEmptyObject ( difference ) && ! isDate ( difference ) && ( isEmptyObject ( lhs [ key ] ) || ! isEmptyObject ( rhs [ key ] ) ) )
35
32
return acc ; // return no diff
36
33
37
34
acc [ key ] = difference // return updated key
0 commit comments