Questions tagged [escodegen]
6 questions
5
votes
1 answer
Why does escodegen and esprima generate a parenthesis wrapper on my source code?
I am using escodegen to add an ending code on my statement as below. In the leave method, I append a .toArray() call on the end of the statement.
const esprima = require('esprima');
const estraverse = require('estraverse');
const escodegen =…

Joey Yi Zhao
- 37,514
- 71
- 268
- 523
1
vote
0 answers
How to add a custom operator to Javascript or node.js with BabelJS?
I would like to add custom operators, keywords, and syntax to Javascript.
Someone asked for help with this many years ago and got some great instructions:
How would I extend the JavaScript language to support a new operator?
Implemented…

abalter
- 9,663
- 17
- 90
- 145
1
vote
2 answers
What's the safest way to allow JavaScript written on the client, to be executed on the server?
I would like to allow our users to write string parsing logic in JavaScript, that would then be executed on the server.
Edit (more info):
Regex is not an option as they will need if, else, switch etc
I would like to avoid creating a custom…

John Doherty
- 3,669
- 36
- 38
1
vote
1 answer
Why isn't .replace() working on a large generated string from escodege.generate()?
I am attempting to generate some code using escodegen's .generate() function which gives me a string.
Unfortunately it does not remove completely the semi-colons (only on blocks of code), which is what I need it to do get rid of them myself. So I am…

theJuls
- 6,788
- 14
- 73
- 160
1
vote
2 answers
Error generating code with escodegen after node removal
First I created an esprima AST, then I want to remove a node using estraverse and finally regenerate the code with escodegen.
But I get an error.
The code I'm trying is:
var esprima = require('esprima');
var estraverse = require('estraverse');
var…

fonkap
- 2,469
- 1
- 14
- 30
0
votes
1 answer
escodegen.generate throws Error: Unknown node type: undefined
The following is the code that I have written
`js
var esprima = require('esprima');
var escodegen = require('escodegen');
var a = "var a = 2";
var ast = esprima.tokenize(a);
var output = escodegen.generate(ast);
console.log(output);
`
I…

Vishal
- 29
- 7