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

Dot syntax for accessing deeply nested properties. #125

Open
ryardley opened this issue Mar 27, 2020 · 1 comment
Open

Dot syntax for accessing deeply nested properties. #125

ryardley opened this issue Mar 27, 2020 · 1 comment

Comments

@ryardley
Copy link
Owner

ryardley commented Mar 27, 2020

It could be useful to have a dot syntax for deeply nested objects:

const isAdmin = p`{ user.roles: [? "admin" ] }`

isAdmin({
  user: {
    roles: [ "editor", "admin" ]
  }
}); // true
@ryardley
Copy link
Owner Author

ryardley commented Mar 29, 2020

With optional properties no need for optional coalescing as the property is explorative.

const isAdmin = p`{ user.roles?: [? "admin" ] }`

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

1 participant