We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
the below code will get a return value showed in the picture below. I dont want an invalid value to override the value of the target.
var deepmerge = require("deepmerge")
const combineMerge = (target, source, options) => { if (typeof source[0] === 'string') { return source; }
const destination = target.slice() source.forEach((item, index) => { if (typeof destination[index] === 'undefined') { destination[index] = options.cloneUnlessOtherwiseSpecified(item, options) } else if (options.isMergeableObject(item)) { destination[index] = deepmerge(target[index], item, options) } else if (target.indexOf(item) === -1) { destination.push(item) } }) return destination
}
const options = { arrayMerge: combineMerge, customMerge: (key, options) => { return undefined } }
const alex = { name: { first: 'Alex', last: 'Alexson' }, pets: ['Cat', 'Parrot'] }
const tony = { name: { first: undefined, last: 'Tonison' }, pets: ['Dog'] }
const result = deepmerge(alex, tony, options)
The text was updated successfully, but these errors were encountered:
I believe this is by design. You'd need to use define a custommerge function if you want to change this behavior.
This is also by design in my library (deepmerge-ts) but this behavior can be overridden. Here's the example of doing that: RebeccaStevens/deepmerge-ts#25
Sorry, something went wrong.
No branches or pull requests
the below code will get a return value showed in the picture below. I dont want an invalid value to override the value of the target.
var deepmerge = require("deepmerge")
const combineMerge = (target, source, options) => {
if (typeof source[0] === 'string') {
return source;
}
}
const options = {
arrayMerge: combineMerge,
customMerge: (key, options) => {
return undefined
}
}
const alex = {
name: {
first: 'Alex',
last: 'Alexson'
},
pets: ['Cat', 'Parrot']
}
const tony = {
name: {
first: undefined,
last: 'Tonison'
},
pets: ['Dog']
}
const result = deepmerge(alex, tony, options)
The text was updated successfully, but these errors were encountered: