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

Fix setting of default values #436

Merged
merged 7 commits into from
Mar 30, 2019

Conversation

mykola-mokhnach
Copy link
Contributor

Object.assign is sometimes not exactly we'd like to use for setting the default values. For example:

d = _.defaults({a: 1}, {b:2}, {c:undefined, a:undefined});
JSON.stringify(d) //{ "a":1,"b":2}
d = Object.assign({a: 1}, {b:2}, {c:undefined, a:undefined});
JSON.stringify(d) //{ "a":1undefined, "b":2, "c": undefined}

Addresses appium/appium#12409

Copy link
Contributor

@dpgraham dpgraham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I wish there was a lint rule that could catch this type of problem.

@imurchie
Copy link
Contributor

You can also just flip the Object.assign arguments:

> d = _.defaults({a: 1}, {b:2}, {c:undefined, a:undefined});
{ a: 1, b: 2, c: undefined }
> d = Object.assign({a: 1}, {b:2}, {c:undefined, a:undefined});
{ a: undefined, b: 2, c: undefined }
> JSON.stringify(d) //{ "a":1undefined, "b":2, "c": undefined}
'{"b":2}'
> d = Object.assign({c:undefined, a:undefined}, {a: 1}, {b:2});
{ c: undefined, a: 1, b: 2 }

@mykola-mokhnach mykola-mokhnach merged commit 7b041a1 into appium:master Mar 30, 2019
@mykola-mokhnach mykola-mokhnach deleted the shell_timeout branch March 31, 2019 19:37
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

Successfully merging this pull request may close these issues.

None yet

3 participants