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

get a null path not return the defaultValue #77

Closed
yesmeck opened this issue Jan 8, 2017 · 4 comments
Closed

get a null path not return the defaultValue #77

yesmeck opened this issue Jan 8, 2017 · 4 comments

Comments

@yesmeck
Copy link

yesmeck commented Jan 8, 2017

See https://runkit.com/586945e631af31001472d7f4/5871ebc5fe814b0013db83e5

Current behavior:

return the whole object.

Expected behavior:

return the defaultValue.

Related code:

object-path/index.js

Lines 224 to 229 in 2b80d6c

if (!path || path.length === 0) {
return obj;
}
if (obj == null) {
return defaultValue;
}

@mariocasciaro
Copy link
Owner

Null path is equivalent to an empty path, so the entire object is returned. This is the expected result.

@yesmeck
Copy link
Author

yesmeck commented Jan 9, 2017

Ok then, are these lines

object-path/index.js

Lines 227 to 229 in 2b80d6c

if (obj == null) {
return defaultValue;
}
dead code?

@mariocasciaro
Copy link
Owner

mariocasciaro commented Jan 9, 2017

That line checks the object not the path. 😉

@yesmeck
Copy link
Author

yesmeck commented Jan 9, 2017

Sorry, miss it.

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