Skip to content

Commit

Permalink
Merge pull request apertureless#186 from apertureless/feature/lodash-…
Browse files Browse the repository at this point in the history
…merge

remvove lodash merge
  • Loading branch information
apertureless authored Sep 2, 2017
2 parents 8271294 + d26078f commit 491625b
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 9 deletions.
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@
"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",
"prepublish": "yarn run lint && yarn run test && yarn run build"
},
"dependencies": {
"lodash": "^4.17.4"
},
"dependencies": {},
"peerDependencies": {
"chart.js": "^2.6.0",
"vue": "^2.4.2"
Expand Down
5 changes: 2 additions & 3 deletions src/helpers/options.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import merge from 'lodash/fp/merge'

export function mergeOptions (obj, src) {
return merge(obj, src)
let mutableObj = Object.assign({}, obj)
return Object.assign(mutableObj, src)
}
28 changes: 26 additions & 2 deletions test/unit/specs/helpers/options.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,40 @@ describe('mergeOptions.js', () => {
c: 'c'
}

const an = {
a: {
a: 'a'
},
b: {
b: 'a'
}
}

const bn = {
a: {
a: 'a'
},
b: {
b: 'b'
}
}

it('should replace old a and b if a and b are new', () => {
let ab = mergeOptions(a, b)
const ab = mergeOptions(a, b)
expect(ab).to.have.property('a').and.to.equal('b')
expect(ab).to.have.property('b').and.to.equal('b')
})

it('should add c if c is new', () => {
let ac = mergeOptions(a, c)
const ac = mergeOptions(a, c)
expect(ac).to.have.property('a').and.to.equal('a')
expect(ac).to.have.property('b').and.to.equal('a')
expect(ac).to.have.property('c').and.to.equal('c')
})

it('should replace old a and b if a and b are new in nested objects', () => {
const ab = mergeOptions(an, bn)
expect(ab).to.have.deep.property('a.a').and.to.equal('a')
expect(ab).to.have.deep.property('b.b').and.to.equal('b')
})
})
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3554,7 +3554,7 @@ lodash@^3.8.0:
version "3.10.1"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6"

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:
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:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"

Expand Down

0 comments on commit 491625b

Please sign in to comment.