Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pifke.org/estree

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pifke.org/estree

  • v0.0.0-20210215195849-bee38bbe3055
  • Go
  • Socket score

Version published
Created
Source

pifke.org/estree

Go (Golang) implementation of the ESTree Specification, an Abstract Syntax Tree for working with Javascript code.

ESTree allows interoperability between software which parses, manipulates, and/or executes Javascript code. Examples include transpilers, minifiers, and front-end frameworks.

This library provides type-checked objects representing AST nodes, which can be serialized to and from JSON in the format used by compilers such as Acorn, Babel, Typescript, etc.

Example

The following Javascript:

function hello(name) {
  var greeting = "Hello";
  console.log(greeting + " " + name);
}

...can be represented as:

Program{
  Body: []DirectiveOrStatement{
    FunctionDeclaration{
      ID:     Identifier{Name: "hello"},
      Params: []Pattern{
        Identifier{Name: "name"},
      },
      Body:   FunctionBody{
        Body: []DirectiveOrStatement{
          VariableDeclaration{
            Declarations: []VariableDeclarator{
              VariableDeclarator{
                ID:   Identifier{Name: "greeting"},
                Init: StringLiteral{Value: "Hello"},
              },
            },
            Kind: Var,
          },
          ExpressionStatement{
            Expression: CallExpression{
              Callee: MemberExpression{
                Object:   Identifier{Name: "console"},
                Property: Identifier{Name: "log"},
              },
              Arguments: []Expression{
                BinaryExpression{
                  Left: BinaryExpression{
                    Left:     Identifier{Name: "greeting"},
                    Operator: Add,
                    Right:    StringLiteral{Value: " "},
                  },
                  Operator: Add,
                  Right:    Identifier{Name: "name"},
                },
              },
            },
          },
        },
      },
    },
  },
}

Roadmap

Only the ES5 nodes have been implemented so far. The remainder are coming very soon.

I'll declare this library 1.0 once I have some real-world experience using it; I built this with a particular project in mind, so this will hopefully also be soon.

Downloading

If you use this library in your own code, please use the canonical URL in your Go code, instead of Github:

go get pifke.org/estree

As opposed to the pifke.org URL, I make no guarantee this Github repository will exist or be up-to-date in the future.

License

MIT (Expat), see LICENSE.txt. If for some reason you'd like to use this code and that doesn't work for you, please contact me.

The ESTree Specification itself is Copyright Mozilla Contributors and ESTree Contributors, Creative Commons Sharealike.

Author

Dave Pifke. My email address is my first name "at" my last name "dot org."

I'm @dave@pifke.social in the Fediverse, @dave:pifke.chat in Matrix, and dpifke on Freenode. My PGP key is available from my web site.

FAQs

Package last updated on 15 Feb 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc