https://github.com/anko/eslisp-propertify
eslisp macro: a.b → (. a b)
https://github.com/anko/eslisp-propertify
Last synced: 4 months ago
JSON representation
eslisp macro: a.b → (. a b)
- Host: GitHub
- URL: https://github.com/anko/eslisp-propertify
- Owner: anko
- Created: 2015-09-15T21:03:46.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-05-05T15:28:26.000Z (about 9 years ago)
- Last Synced: 2025-07-01T11:51:58.517Z (12 months ago)
- Language: Makefile
- Homepage:
- Size: 12.7 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# eslisp-propertify [][1] [][2] [][3]
An [eslisp][4] macro that rewrites its input forms' atoms that contain dots
into property accesses. This means you can write `x.y.1` instead of `(. x y
1)`, which compiles to JS as `x.y[1];`.
Ignores trailing and leading dots, and atoms that consist of dots.
## Example
(macro propertify (require "/path/to/elisp-propertify/index.js"))
(propertify (a.b 42))
↓
a.b(42);
See [the tests][5] for fuller usage.
## Full wrap
It's totally reasonable to wrap your whole program in this. Consider the
eslisp compiler's `--transform` flag.
## Limitations
If you need a computed member expression, you'll still need the `.` macro: For
example, to get `a.b[b.length]`, you'll need to write `(. a.b b.length)`.
## License
[ISC][6].
[1]: https://www.npmjs.com/package/eslisp-propertify
[2]: https://travis-ci.org/anko/eslisp-propertify
[3]: https://gitter.im/anko/eslisp
[4]: https://www.npmjs.com/package/eslisp
[5]: test.esl
[6]: http://opensource.org/licenses/ISC