[英]How do i create an await expression using recast/esprima
I have a js function 我有一个js功能
export const cleanUp = async () => {
await User.destroy({ where: {} });
};
I am trying to insert a line below await User.destroy({ where: {} })
using 我试图在
await User.destroy({ where: {} })
下面插入一行
recast.parse(`await ${module}.destroy({ where: {} });`);
But I keep. 但我保持。 getting
Unexpected Identifier
because esprima expects an async declaration. 得到
Unexpected Identifier
因为esprima期望异步声明。 How else can I achieve this? 我怎么能做到这一点?
esprima claims "Full support for ECMAScript 2016 (ECMA-262 7th Edition)" while "await" initial definition was in "ECMAScript 2017 (ECMA-262)" esprima声称“完全支持ECMAScript 2016(ECMA-262第7版)”而“等待”初始定义在“ECMAScript 2017(ECMA-262)”中
I think this can be the problem. 我认为这可能是问题所在。
http://esprima.org/ (Features paragraph) http://esprima.org/ (特刊段落)
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#Specifications https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#Specifications
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.