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

Does Array values concat instead of be replaced? #8

Open
Shoroh opened this issue Aug 1, 2018 · 0 comments
Open

Does Array values concat instead of be replaced? #8

Shoroh opened this issue Aug 1, 2018 · 0 comments

Comments

@Shoroh
Copy link

Shoroh commented Aug 1, 2018

I'm not sure, if this a bug or a feature. Look:

import merge from 'merge-deep';

const object1 = { a: '1', b: '2', c: [1, 2, 3] };
const object2 = { a: undefined, b: null, c: null }; // 'c' property might be anything else, like '1', or undefined, or an empty Array, doesn't matter

const mergedObject = merge(object1, object2);
console.log(mergedObject);
=> { a: undefined, b: null, c: [1, 2, 3] } // So, the last property is not changed.

If 'c' in the object2 was 'abc', we'll get

=> { a: undefined, b: null, c: ['abc', 1, 2, 3] }

It looks like Array type values concat, instead of be replaced with a new value. But I need a tool to replace values while merging.

Should I use assign-deep instead? Cause the last one does it well.

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

1 participant