By default, deepmerge clones every property from almost every kind of object.
You may not want this, if your objects are of special types, and you want to copy the whole object instead of just copying its properties.
You can accomplish this by passing in a function for the isMergeableObject option.
If you only want to clone properties of plain objects, and ignore all "special" kinds of instantiated objects, you probably want to drop in is-plain-object.
const { isPlainObject } = require('is-plain-object')function SuperSpecial() { this.special = 'oh yeah man totally'}const instantiatedSpecialObject = new SuperSpecial()const target = { someProperty: { cool: 'oh for sure' }}const source = { someProperty: instantiatedSpecialObject}const defaultOutput = merge(target, source)defaultOutput.someProperty.cool // => 'oh for sure'defaultOutput.someProperty.special // => 'oh yeah man totally'defaultOutput.someProperty
customMerge
Specifies a function which can be used to override the default merge behavior for a property, based on the property name.
The customMerge function will be passed the key for each property, and should return the function which should be used to merge the values for that property.
It may also return undefined, in which case the default merge behaviour will be used.