deepmerge
deepmerge copied to clipboard
When source is undefined, mergedeep returns source
_deepmerge(target, source) returns source when source is undefined, rather it should be target.
example: ` const deepmergeFastify = require('@fastify/deepmerge')({clone: false}) let target: {key: value} const source: undefined
target = deepmergeFastify(target, source)
// target will be undefined here
But target should be returned as is. I suspect the issue might be at this line https://github.com/fastify/deepmerge/blob/main/index.js#L136
Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.
Is the intended/expected behavior to return target?
For instance, Object.assing() throws an error when target is undefined or null and with the proposed fix it will return the target value.
> Object.assign(undefined, {})
Uncaught TypeError: Cannot convert undefined or null to object
at Function.assign (<anonymous>)