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

Useless deepmerge #320

Closed
zdm opened this issue Sep 15, 2020 · 4 comments
Closed

Useless deepmerge #320

zdm opened this issue Sep 15, 2020 · 4 comments

Comments

@zdm
Copy link

zdm commented Sep 15, 2020

Hi.
Are you sure, that deepmerge is needed here:

    async launch(options) {
        // Ensure there are certain properties (e.g. the `options.args` array)
        const defaultLaunchOptions = { args: [] };
        options = merge(defaultLaunchOptions, options);

Why not just write:

async launch(options = {}) {
    if (!options.args) options.args = [];

I am asking, because deepmerge works incorrectly in my case. I need to pass options.proxy as instance of Proxy class, but deepmerge converts it to the plain object.

@zdm
Copy link
Author

zdm commented Sep 15, 2020

Or do not merge, if object is not a plain object:

const isPlainObject = require('is-plain-object')
merge(target, source, {
    isMergeableObject: isPlainObject
});

@Niek
Copy link
Collaborator

Niek commented Sep 15, 2020

Feel free to submit a PR, but please be aware that if (!options.args) options.args = []; is something very different than merging the two option arrays.

@zdm
Copy link
Author

zdm commented Sep 15, 2020

PR
#322

@Niek
Copy link
Collaborator

Niek commented Sep 15, 2020

Closing this in favor of #322

@Niek Niek closed this as completed Sep 15, 2020
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

2 participants