We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Hi there,
Is it possible to add toplevel await? Right now babel says the following, so im not sure if its supported:
await' is only allowed within async functions and at the top levels of modules. (1:12)
The code:
"use strict"; const start = Date.now(); process.on("exit", () => console.log('Time: ' + Date.now() - start + 'ms')); // const esprima = require('esprima'); const babel = require("@babel/parser"); const { evaluate } = require("eval-estree-expression"); const { generate } = require("escodegen"); // const parse = (input, options) => esprima.parse(input).body[0].expression; const parse = (input, options) => babel.parseExpression(input, options); const context = { n: 6, foo: async function (x) { return (await x) * 100; }, bar: async (x, y) => (await x) * 100 * y, obj: { x: { y: 555 } }, z: 3, console, }; const input = 'console.log(await foo(1));'; const tree = parse(input); evaluate(tree, context, { functions: true, generate }) .then(console.log) .catch(console.error);
The text was updated successfully, but these errors were encountered:
Hmm, I think that might just be a babel option. I'll look into it unless someone else beats me to it.
Sorry, something went wrong.
I'd be open to a PR for this, I haven't had time to look into it yet.
No branches or pull requests
Hi there,
Is it possible to add toplevel await?
Right now babel says the following, so im not sure if its supported:
The code:
The text was updated successfully, but these errors were encountered: