Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Functions are not supported #9

Open
saitamachoudhary opened this issue Nov 5, 2024 · 2 comments
Open

TypeError: Functions are not supported #9

saitamachoudhary opened this issue Nov 5, 2024 · 2 comments

Comments

@saitamachoudhary
Copy link

I have tried to run this code as mention in docs but getting error
const { parse } = require('esprima');
const { evaluate } = require('eval-estree-expression');
const ast = parse('[1, 2, 3].map(n => n * x);').body[0].expression;

// evaluate synchronously
console.log(evaluate.sync(ast)); // => [2, 4, 6]

// or asynchronously
console.log(await evaluate(ast)); // => [2, 4, 6]

@WesWrench
Copy link

Hello, same problem for me.
I try to parse "console.log('test');" and evaluate synchronously with evaluate.sync(ast, window) in my browser and i have the same error.

@jonschlinkert
Copy link
Owner

You need to set { functions: true } on the options. https://github.com/jonschlinkert/eval-estree-expression?tab=readme-ov-file#functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants