acorn-es7-plugin
acorn-es7-plugin is a plugin for the Acorn parser that generates ESTrees following the 'experimental' specification for asynchronous functions.
npm install --save acorn-es7-plugin
Usage
Adding the plugin
// Require acorn as usual
var acorn = require("acorn");
// Add the es7-plugin
require('./acorn-es7-plugin')(acorn) ;
Using the plugin
var code = "async function x(){ return ; }\n";
code += "await x(1);" ;
var ast = acorn.parse(code,{
// Specify use of the plugin
plugins:{asyncawait:true},
// Specify the ecmaVersion
ecmaVersion:7
}) ;
// Show the AST
console.log(JSON.stringify(ast,null,2)) ;