[go: nahoru, domu]

Skip to content

Commit

Permalink
initial
Browse files Browse the repository at this point in the history
  • Loading branch information
75lb committed Nov 15, 2018
0 parents commit 283f1f1
Show file tree
Hide file tree
Showing 4 changed files with 362 additions and 0 deletions.
14 changes: 14 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function deepMerge (...args) {
const assignWith = require('lodash.assignwith')
const t = require('typical')

function customiser(objValue, srcValue) {
if (t.isPlainObject(objValue) && t.isPlainObject(srcValue)) {
return assignWith(objValue, srcValue, customiser)
}
}

return assignWith(...args, customiser)
}

module.exports = deepMerge
317 changes: 317 additions & 0 deletions package-lock.json

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

18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "deep-merge",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"test-runner": "^0.5.0"
},
"dependencies": {
"lodash.assignwith": "^4.2.0",
"typical": "^3.0.0"
}
}
13 changes: 13 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
const TestRunner = require('test-runner')
const a = require('assert')
const deepMerge = require('./')

const runner = new TestRunner()

runner.test('simple', function () {
const result = deepMerge({ a: 1 }, { b: 2 })
a.deepEqual({
a: 1,
b: 2
})
})

0 comments on commit 283f1f1

Please sign in to comment.