File tree 2 files changed +7
-9
lines changed
2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change 9
9
},
10
10
"author" : " Matt Phillips" ,
11
11
"license" : " ISC" ,
12
- "dependencies" : {
13
- "lodash" : " ^4.17.2"
14
- },
15
12
"devDependencies" : {
16
13
"babel-cli" : " ^6.18.0" ,
17
14
"babel-core" : " ^6.18.2" ,
Original file line number Diff line number Diff line change 1
- import isEqual from 'lodash/fp/isEqual' ;
1
+ const isObject = o => typeof o === 'object' ;
2
+ const isEmpty = o => Object . keys ( o ) . length === 0 ;
2
3
3
4
const diff = ( lhs , rhs ) => {
4
- if ( isEqual ( lhs , rhs ) ) return { } ;
5
+ if ( lhs === rhs ) return { } ;
5
6
6
7
if ( typeof rhs !== 'object' || rhs === null ) return rhs ;
7
8
@@ -14,11 +15,11 @@ const diff = (lhs, rhs) => {
14
15
return rhsKeys . reduce ( ( acc , key ) => {
15
16
if ( ! lhs . hasOwnProperty ( key ) ) return { ...acc , [ key ] : rhs [ key ] } ;
16
17
17
- const lhsValue = lhs [ key ] ;
18
- const rhsValue = rhs [ key ] ;
19
- if ( isEqual ( lhsValue , rhsValue ) ) return acc ;
18
+ const difference = diff ( lhs [ key ] , rhs [ key ] ) ;
20
19
21
- return { ...acc , [ key ] : diff ( lhsValue , rhsValue ) } ;
20
+ if ( isObject ( difference ) && isEmpty ( difference ) ) return acc ;
21
+
22
+ return { ...acc , [ key ] : difference } ;
22
23
} , deletedValues ) ;
23
24
} ;
24
25
You can’t perform that action at this time.
0 commit comments