-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
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
deepmerge and deepmerge.all behave differently with certain options #201
Comments
I think the root cause is that |
here's a potential fix, but it might not work right if the array is <2 elements in length... I'm not sure. function deepmergeAll(array, options) {
if (!Array.isArray(array)) {
throw new Error(`first argument should be an array`)
}
return array.slice(1).reduce((prev, next) => deepmerge(prev, next, options), array[0] || {})
} |
Oh hey, that's interesting. I think for arrays passed in with 2+ elements, the nicest solution would be to just not pass in an initial value to If we made that change, I think we'd have to handle the 0 and 1 element cases specifically – if the array has 0 elements, return |
deepmerge(a, b, opts)
anddeepmerge.all([a, b], opts)
behave differently given certain options.Repro:
The text was updated successfully, but these errors were encountered: