Skip to content

Commit

Permalink
Simplify merge conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
timhudson committed May 8, 2019
1 parent bc70315 commit cc67fbb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/index.js
Expand Up @@ -42,12 +42,10 @@ export const merge = (a, b) => {
result[key] = a[key]
}
for (const key in b) {
if (!a[key]) {
if (!a[key] || typeof a[key] !== 'object') {
result[key] = b[key]
} else if (typeof a[key] === 'object') {
result[key] = merge(a[key], b[key])
} else {
result[key] = b[key]
result[key] = merge(a[key], b[key])
}
}
return result
Expand Down

0 comments on commit cc67fbb

Please sign in to comment.