Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function Tree(source, escodegenOptions, acornOptions) {
this.acornOptionDefaults = _.extend({}, acornOptionDefaults, acornOptions);
this.comments = [];
this.tokens = [];
this.acornOptionDefaults.onComment = this.comments;
this.acornOptionDefaults.onToken = this.tokens;
this.tree = acorn.parse(source.toString(), this.acornOptionDefaults);
this.tree = escodegen.attachComments(this.tree, this.comments, this.tokens);
this.body = new Body(this.tree.body, this.acornOptionDefaults);
this.escodegenOptions = _.extend({}, escodegenOptionDefaults, escodegenOptions);
}
const generateCode = (ast) => {
const astWithComments = escodegen.attachComments(
ast,
ast.comments,
ast.tokens
);
return escodegen.generate(
astWithComments,
{
comment: true,
format: { index: { style: ' ' } },
}
);
};
var generateCode = function generateCode(ast) {
var astWithComments = escodegen.attachComments(ast, ast.comments, ast.tokens);
return escodegen.generate(astWithComments, {
comment: true,
format: { index: { style: ' ' } }
});
};
exports.create = function (valStr) {
this.comments = [];
this.tokens = [];
acornOptions.onComment = this.comments;
acornOptions.onToken = this.tokens;
var tree = acorn.parse('var astValFactory = ' + valStr, acornOptions);
tree = escodegen.attachComments(tree, this.comments, this.tokens);
return tree.body[0].declarations[0].init;
};