xxx.js 418 B

123456789101112131415
  1. (function () {
  2. "use strict";
  3. const acorn = require('acorn'); // 3.x
  4. require('..')(acorn);
  5. var code = "(async function x(){ console.log('hello'); }());";
  6. var ast = acorn.parse(code,{
  7. // Specify use of the plugin
  8. plugins:{asyncawait:true},
  9. // Specify the ecmaVersion
  10. ecmaVersion: 7
  11. }) ;
  12. // Show the AST
  13. console.log(JSON.stringify(ast,null,2)) ;
  14. }());