[go: nahoru, domu]

Skip to content

Commit

Permalink
node v14.. add dist
Browse files Browse the repository at this point in the history
  • Loading branch information
75lb committed Jun 9, 2021
1 parent ec80180 commit 0adfa45
Show file tree
Hide file tree
Showing 8 changed files with 2,228 additions and 188 deletions.
692 changes: 692 additions & 0 deletions dist/index.mjs

Large diffs are not rendered by default.

14 changes: 0 additions & 14 deletions index.js

This file was deleted.

23 changes: 23 additions & 0 deletions index.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import assignWith from 'lodash.assignwith'
import { isPlainObject, isDefined } from 'typical'

function customiser (previousValue, newValue, key, object, source) {
/* deep merge plain objects */
if (isPlainObject(previousValue) && isPlainObject(newValue)) {
return assignWith(previousValue, newValue, customiser)
/* overwrite arrays if the new array has items */
} else if (Array.isArray(previousValue) && Array.isArray(newValue) && newValue.length) {
return newValue
/* ignore incoming arrays if empty */
} else if (Array.isArray(newValue) && !newValue.length) {
return previousValue
} else if (!isDefined(previousValue) && Array.isArray(newValue)) {
return newValue
}
}

function deepMerge (...args) {
return assignWith(...args, customiser)
}

export default deepMerge
Loading

0 comments on commit 0adfa45

Please sign in to comment.