TL;DR: i want to do same thing as there https://github.com/nolanlawson/optimize-js but with esprima
when i traverse through AST tree with estraverse
.
ESPrima gives same output nodes for following code:
!function (){}()
and
!(function (){})()
http://esprima.org/demo/parse.html?code=!function%20()%7B%7D()%0A%0A!(function%20()%7B%7D)()
For example - i will traverse through AST tree. On Function Expression ExpressionStatement node i want to check - if that node doesn't have parens around function - i want to add it.
So, how i can detect function parens, how i can add them? I look at tokens, but i have no idea how i can associate flat tokens object with object with specified AST node.