-
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
#185 change customMerge signature for merging empty values #228
base: v5
Are you sure you want to change the base?
Conversation
… or empty string overwrites + a sweet little util function customMergeIgnoreEmptyValues for cuteness
b965118
to
03a63cc
Compare
Should this not be deepmerge.customMergeIgnoreEmptyValues = (key, target, source) => !target || target === ''
? () => source
: deepmerge; otherwise the you only get a shallow copy? Though you could always supply your own function I guess. |
No it's meant to be used as customMerge option. if you look at the test i provided on test/merge.js line: 680. Maybe i should have named it differently? Also i might be misunderstanding what you mean. |
If you change the test a little: src = { someNewVariable: { key: "herp"}, very: { nested: { thing: "", another: "derp" } } };
target = { very: { nested: { thing: "derp", another: "" } } }; And run the test with the default merge you will get the overwritten thing : With the customMergeIgnoreEmptyValues merge function you get: It does not look trivial to implement but is also what I expected. |
oh crap that's what i want as well. Let me digg a little more. |
@TehShrike original pr: #205
My rebase got in a weird state so i just redid it and cleaned it up a bit