Hacker News new | ask | show | jobs
by vosper 390 days ago
> JavaScript ORMs would be revolutionized if they had this ability.

Is this possible in JavaScript?

2 comments

Not easily. There's no built-in way to access the abstract syntax tree (or equivalent) of a function at run time. The best thing you can do is to obtain the source code of a function using `.toString()` and then use a separate JS parser to process it, but that's not a very realistic option.
There is a limited form of such "expression rewriting" using tagged template strings introduced in ES2015. But it wouldn't be particularly useful for the ORM case.