eslisp-propertify
v0.3.0
Published
eslisp macro that converts atoms containing dots into property access expressions
Downloads
104
Readme
eslisp-propertify
An eslisp 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 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.