acorn-es7
ES7 decorators support for Acorn.
Last updated 10 years ago by angelozerr .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install acorn-es7 
SYNC missed versions from official npm registry.

acorn-es7

ES7 support for Acorn. It works with node.js and plain browser:

** decorators: ** works with acorn and acorn loose parser. ** provides a walk ** async/await ** see acorn-es7-plugin

Usage

See sample.js:

// Require acorn as usual
var acorn = require("acorn");
// Add the es7-plugin
require('./acorn-es7')(acorn) ;

var code = "@Component()\n class AppComponent{}"; 
var ast = acorn.parse(code,{
    // Specify use of the plugin
    plugins:{es7:true},
    // Specify the ecmaVersion
    ecmaVersion:7
}) ;
// Show the AST
console.log(JSON.stringify(ast, null, 1)) ;
@Component()
class AppComponent{}
{
 "type": "Program",
 "start": 0,
 "end": 34,
 "body": [
  {
   "type": "ClassDeclaration",
   "start": 0,
   "end": 34,
   "id": {
    "type": "Identifier",
    "start": 20,
    "end": 32,
    "name": "AppComponent"
   },
   "superClass": null,
   "body": {
    "type": "ClassBody",
    "start": 32,
    "end": 34,
    "body": []
   },
   "decorators": [
    {
     "type": "Decorator",
     "start": 0,
     "end": 12,
     "expression": {
      "type": "CallExpression",
      "start": 1,
      "end": 12,
      "callee": {
       "type": "Identifier",
       "start": 1,
       "end": 10,
       "name": "Component"
      },
      "arguments": []
     }
    }
   ]
  }
 ],
 "sourceType": "script"
}

Current Tags

  • 0.1.0                                ...           latest (10 years ago)

1 Versions

  • 0.1.0                                ...           10 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 1
Dependencies (1)
Dev Dependencies (0)
None

Copyright 2013 - present © cnpmjs.org | Home |