-
-
Notifications
You must be signed in to change notification settings - Fork 10
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 non-existing fields #522
Comments
The result of the merge should have all the fields of const x = deepmerge(y1, y2); https://codesandbox.io/p/sandbox/deepmerge-ts-example-forked-nx5sp7 deepmergeInto(y1, y2); https://codesandbox.io/p/sandbox/deepmerge-ts-example-forked-t9y227 |
If I merge y1 and y2, I want to overwrite the fields in y1 with the existing fields of y2. Example: const y1 = {
field1: "value1",
field2: {
a: 0,
b: 1
}
}
const y2 = {
field1: "newvalue",
field3: "newvalue2"
}
const newObject = deepmerge(y1, y2);
Output:
{
field1: "newvalue",
field2: {
a: 0,
b: 1
},
field3: "newvalue2"
} |
That's exactly how it works: https://codesandbox.io/p/sandbox/deepmerge-ts-example-forked-nx5sp7 |
Thank you for showing me an example. |
I am wondering if this is possible, as I haven't seen it in the docs.
I want to merge 2 objects y1 and y2.
If I do:
deepmerge(y1, y2)
and y2 has some fields that don't exist in y1, it wont override or add them at all.
I am wondering if it's possible to change this.
Thank you.
The text was updated successfully, but these errors were encountered: