Skip to content

Commit

Permalink
Remove lodash.merge
Browse files Browse the repository at this point in the history
  • Loading branch information
unional committed Oct 20, 2017
1 parent 99716c7 commit 82e8032
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
3 changes: 2 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Expand Up @@ -64,9 +64,7 @@
"**/test/**/*"
]
},
"dependencies": {
"lodash.merge": "^4.6.0"
},
"dependencies": {},
"devDependencies": {
"@types/lodash.merge": "^4.6.3",
"ava": "^0.22.0",
Expand Down
6 changes: 2 additions & 4 deletions src/index.ts
@@ -1,5 +1,3 @@
import merge = require('lodash.merge')

// `partial: Partial<T> | undefined` is better than `partial?: Partial<T>` in this case.
// I want to make sure `partial` is passed in, while it can be optional, i.e. undefined, at caller context.
export function unpartial<T extends object>(base: T, partial: Partial<T> | undefined): T
Expand All @@ -20,12 +18,12 @@ function unpartialTrio(superBase, base, partial) {
if (base === undefined || base === null)
return unpartial(superBase, partial)

return merge({}, superBase, base, partial)
return { ...superBase, ...base, ...partial }
}

function unpartialDuo(base, partial) {
if (partial === undefined || partial === null)
return partial

return merge({}, base, partial)
return { ...base, ...partial }
}

0 comments on commit 82e8032

Please sign in to comment.