File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change 99 },
1010 "author" : " Matt Phillips" ,
1111 "license" : " ISC" ,
12- "dependencies" : {
13- "lodash" : " ^4.17.2"
14- },
1512 "devDependencies" : {
1613 "babel-cli" : " ^6.18.0" ,
1714 "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 ;
23
34const diff = ( lhs , rhs ) => {
4- if ( isEqual ( lhs , rhs ) ) return { } ;
5+ if ( lhs === rhs ) return { } ;
56
67 if ( typeof rhs !== 'object' || rhs === null ) return rhs ;
78
@@ -14,11 +15,11 @@ const diff = (lhs, rhs) => {
1415 return rhsKeys . reduce ( ( acc , key ) => {
1516 if ( ! lhs . hasOwnProperty ( key ) ) return { ...acc , [ key ] : rhs [ key ] } ;
1617
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 ] ) ;
2019
21- return { ...acc , [ key ] : diff ( lhsValue , rhsValue ) } ;
20+ if ( isObject ( difference ) && isEmpty ( difference ) ) return acc ;
21+
22+ return { ...acc , [ key ] : difference } ;
2223 } , deletedValues ) ;
2324} ;
2425
You can’t perform that action at this time.
0 commit comments