Skip to content
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

Recursive merge doesn't handle arrays correctly #13

Closed
dkniffin opened this issue Dec 9, 2014 · 1 comment
Closed

Recursive merge doesn't handle arrays correctly #13

dkniffin opened this issue Dec 9, 2014 · 1 comment

Comments

@dkniffin
Copy link

dkniffin commented Dec 9, 2014

console.log(merge.recursive({'one':['a','b']},{'one':['c','d']}))
=> { one: [ 'c', 'd' ] }

I expected:

=> { one: ['a','b','c','d'] }

In the meantime, it looks like deepmerge does this.

@piranna
Copy link

piranna commented Dec 15, 2014

I think the current behaviour is the correct one. Objects are hash-like, so you can overwrite it content, it's behaviour is clear. But what to do with arrays? Definitely, not append the data, since the "keys" are not the same (you are changing the indexes of the data)... Override the entries of the array with the same index (the same "key")? Override the array itself as if it was a primitive object (numbers, strings...)?

@yeikos yeikos closed this as completed Dec 26, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants