From 82e80322f242db35aa3abd7c312be5e0e4362f89 Mon Sep 17 00:00:00 2001 From: Homa Wong Date: Fri, 20 Oct 2017 15:41:56 -0700 Subject: [PATCH] Remove lodash.merge --- package-lock.json | 3 ++- package.json | 4 +--- src/index.ts | 6 ++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index dce20b1..31a0062 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3012,7 +3012,8 @@ "lodash.merge": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.0.tgz", - "integrity": "sha1-aYhLoUSsM/5plzemCG3v+t0PicU=" + "integrity": "sha1-aYhLoUSsM/5plzemCG3v+t0PicU=", + "dev": true }, "loose-envify": { "version": "1.3.1", diff --git a/package.json b/package.json index 127bc5d..385ad51 100644 --- a/package.json +++ b/package.json @@ -64,9 +64,7 @@ "**/test/**/*" ] }, - "dependencies": { - "lodash.merge": "^4.6.0" - }, + "dependencies": {}, "devDependencies": { "@types/lodash.merge": "^4.6.3", "ava": "^0.22.0", diff --git a/src/index.ts b/src/index.ts index 13949e7..b1d64cc 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,5 +1,3 @@ -import merge = require('lodash.merge') - // `partial: Partial | undefined` is better than `partial?: Partial` 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(base: T, partial: Partial | undefined): T @@ -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 } }