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

hasByPath() #12

Open
ozum opened this issue Apr 28, 2023 · 2 comments
Open

hasByPath() #12

ozum opened this issue Apr 28, 2023 · 2 comments

Comments

@ozum
Copy link

ozum commented Apr 28, 2023

Hi,

Thanks for the library. It would be great if it provided an hasByPath() method to check the path's availability.

Thanks,

@g-makarov
Copy link
Owner

@ozum hi, thanks for feedback :)
Maybe I misunderstood, but why can't you use like this? const hasValue = getByPath(obj, 'a.b.c') !== undefined

@ozum
Copy link
Author

ozum commented May 3, 2023

Hi @g-makarov,

Below is an example for a use case:

const a = {
	name: "Jane"
	surname: undefined
}

const hasValue = getByPath(a, 'surname') !== undefined; // false
const hasValue = hasByPath(a, 'surname'); // true

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