-
Notifications
You must be signed in to change notification settings - Fork 17
adds option to ignore undefined values #14
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
adds option to ignore undefined values #14
Conversation
2 similar comments
I would consider defaulting this option to I'd argue for it to be |
Even though I understand your reasoning for defaulting to |
I think the spread operator is trying to be closer to general-purpose object-merging than merging options specifically - there are plenty of modules out there already that do that recursively. As for backwards compatibility, you can just release a major. Up to you though. |
I have to publish a major anyway, because of node>=8. Regarding your example above, I would argue that the common use case looks like this, which already works at v1.0.0 as expected: const mergeOptions = require('merge-options');
function someFunc (options = {}) {
return someOtherFunc(mergeOptions({
key: 'overridden-default-value'
}, options))
} Please note that you still may const mergeOptions = require('merge-options').bind({ignoreUndefined: true});
mergeOptions({foo: 'bar'}, {foo: undefined})
//=> {foo: 'bar'} |
|
It's common to take
options
arguments and pass some of them on to other functions.If the incoming option is not set, this can result in passing
undefined
on to other functions which can cause surprise if the other function sets up its own default values.This PR adds a
ignoreUndefined
option to not set values toundefined
:Fixes #13