Add option to disable async#246
Conversation
This is done by checking if the source contains the word 'async'. This catches await, since it can only be used in async functions. It wraps eval and function ctors and injects the async check there too. This has some side effects like no direct eval support. The option is currently opt in.
via Object.getPrototypeOf((function*(){}).constructor)
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
|
Thanks for your contribution! I'm sorry I was not able to merge that sooner. |
|
Is there a reason this was implemented with such a broad regex? It ends up blocking things like declaring a variable named Is there a way to only stop async functions? Or perhaps stopping |
|
Stopping await is not needed, since creating an async function and calling it will result in it being run later on, so we need to filter out async functions. The regex is so broad since a better one whould be verry complicated and errorprone, for example whitespaces can contain comments, |
|
@XmiliaH Why not parse the code into an AST and see if any function nodes are marked |
This is done by checking if the source contains the word 'async'.
This catches await, since it can only be used in async functions.
It wraps eval and function ctors and injects the async check there too.
This has some side effects like no direct eval support.
The option is currently opt in.
This should fix #180.