-
Notifications
You must be signed in to change notification settings - Fork 217
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
merge.all with single element array #71
Comments
deepmerge doesn't mutate either argument that is passed in to it, so it's difficult to imagine what would happen if you passed just a single object to it. Would it just be a shallow copy to a new object, like It would be a breaking change, but I think it would be a bit easier to fix this if we made As an aside, I'd personally prefer this to the concat I think: const output = array.length > 1 ? merge.all(array) : array[0] Or if you want the copy: const output = array.length > 1 ? merge.all(array) : merge({}, array[0]) |
My current stance: if we do publish a breaking change to make cloning the default (#72), we can feel free to make this change so that |
As of version 2.0.0, |
I'm curious why when one calls
merge.all()
with a single element array,[{'a':1}]
, this function doesnt just return the value of that first element in the array{'a':1}
? The function is instead throwing an error.In my code, I'm dynamically creating an array of objects that I need to merge together. Occasionally, that array only has one element. To protect against this error I have to add
.concat({})
to the array argument increase its length to 2.The text was updated successfully, but these errors were encountered: