Skip to content

Commit 491625b

Browse files
authored
Merge pull request #186 from apertureless/feature/lodash-merge
remvove lodash merge
2 parents 8271294 + d26078f commit 491625b

File tree

4 files changed

+30
-9
lines changed

4 files changed

+30
-9
lines changed

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,7 @@
5656
"release": "webpack --progress --hide-modules --config ./build/webpack.release.js && NODE_ENV=production webpack --progress --hide-modules --config ./build/webpack.release.min.js && webpack --progress --hide-modules --config ./build/webpack.release.full.js && NODE_ENV=production webpack --progress --hide-modules --config ./build/webpack.release.full.min.js",
5757
"prepublish": "yarn run lint && yarn run test && yarn run build"
5858
},
59-
"dependencies": {
60-
"lodash": "^4.17.4"
61-
},
59+
"dependencies": {},
6260
"peerDependencies": {
6361
"chart.js": "^2.6.0",
6462
"vue": "^2.4.2"

src/helpers/options.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import merge from 'lodash/fp/merge'
2-
31
export function mergeOptions (obj, src) {
4-
return merge(obj, src)
2+
let mutableObj = Object.assign({}, obj)
3+
return Object.assign(mutableObj, src)
54
}

test/unit/specs/helpers/options.spec.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,40 @@ describe('mergeOptions.js', () => {
1515
c: 'c'
1616
}
1717

18+
const an = {
19+
a: {
20+
a: 'a'
21+
},
22+
b: {
23+
b: 'a'
24+
}
25+
}
26+
27+
const bn = {
28+
a: {
29+
a: 'a'
30+
},
31+
b: {
32+
b: 'b'
33+
}
34+
}
35+
1836
it('should replace old a and b if a and b are new', () => {
19-
let ab = mergeOptions(a, b)
37+
const ab = mergeOptions(a, b)
2038
expect(ab).to.have.property('a').and.to.equal('b')
2139
expect(ab).to.have.property('b').and.to.equal('b')
2240
})
2341

2442
it('should add c if c is new', () => {
25-
let ac = mergeOptions(a, c)
43+
const ac = mergeOptions(a, c)
2644
expect(ac).to.have.property('a').and.to.equal('a')
2745
expect(ac).to.have.property('b').and.to.equal('a')
2846
expect(ac).to.have.property('c').and.to.equal('c')
2947
})
48+
49+
it('should replace old a and b if a and b are new in nested objects', () => {
50+
const ab = mergeOptions(an, bn)
51+
expect(ab).to.have.deep.property('a.a').and.to.equal('a')
52+
expect(ab).to.have.deep.property('b.b').and.to.equal('b')
53+
})
3054
})

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3554,7 +3554,7 @@ lodash@^3.8.0:
35543554
version "3.10.1"
35553555
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"
35563556

3557-
lodash@^4.0.0, lodash@^4.0.1, lodash@^4.17.2, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.3.0, lodash@^4.5.0:
3557+
lodash@^4.0.0, lodash@^4.0.1, lodash@^4.17.2, lodash@^4.17.3, lodash@^4.2.0, lodash@^4.3.0, lodash@^4.5.0:
35583558
version "4.17.4"
35593559
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
35603560

0 commit comments

Comments
 (0)