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

Wrap output in parenthesis #1

Closed
jgierer12 opened this issue May 7, 2020 · 2 comments
Closed

Wrap output in parenthesis #1

jgierer12 opened this issue May 7, 2020 · 2 comments
Labels

Comments

@jgierer12
Copy link

Wouldn't wrapping the macro output in parenthesis () largely solve the pitfall you describe in the readme?

For example,

const helloWorld = { hello: 'world' }.hello;

isn't valid JS but

const helloWorld = ({ hello: 'world' }).hello;

is and works as expected.

@ifiokjr
Copy link
Owner

ifiokjr commented May 7, 2020

I had tried, babel seems to remove the brackets. I couldn't figure out how to get it to stop, so just added the warning.

I thought about an ugly hack of wrapping the json in an array and referencing the first item

const helloWorld = [{ hello: 'world' }][0].hello;

This is valid, but very ugly and I'm not sure of the performance implications for larger pieces of data.

I don't know babel very well, this is my first plugin, so it's probably a simple fix that I'm not aware of.

Any idea how this can be done?

@ifiokjr ifiokjr closed this as completed in 531fa1f May 7, 2020
github-actions bot pushed a commit that referenced this issue May 7, 2020
## [1.2.0](v1.1.0...v1.2.0) (2020-05-07)

### Features

* add path getter to `loadJson` method for picking desired property ([15320a7](15320a7))
* allow chaining of methods by wrapping in parentheses ([531fa1f](531fa1f)), closes [#1](#1)
@github-actions
Copy link

github-actions bot commented May 7, 2020

🎉 This issue has been resolved in version 1.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants