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

reflect

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

reflect

JavaScript parser adhering to Mozilla's parser API

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
485
increased by54.46%
Maintainers
1
Weekly downloads
 
Created
Source

Reflect.js

Reflect.js is a JavaScript (ES3 compatible) implementation of Mozilla's Parser API. It does not currently support some of Mozilla's extensions, such as generators, list comprehensions, for each, E4X, etc. but may eventually support ones that are, or become Harmony proposals. Builders are also supported.

Parsing really large files can be slow, for reasons articulated by Andy Chu.

Download

You can download a minified-standalone version of reflect.js to embed in web pages here.

Install

Reflect.js is available as a CommonJS module for Node.js. Simply install it with npm:

npm install reflect

Use

var Reflect = require('reflect');

var ast = Reflect.parse("var a = 4 + 7");

console.log(Reflect.stringify(ast, "  "));

Refer to Mozilla's docs for details on the AST interface.

Builders

The optional builder parameter to Reflect.parse() makes it possible to construct user-specified data from the parser, rather than the default Node objects.

The reflect.js module exports the default builder so you can redefine only the node constructors you care about and leave the rest default.

var Reflect = require('reflect');
var builder = Reflect.builder;

// redefine callback for variable declarations
builder["variableDeclaration"] = function (kind, declarators, loc) { ... };

var ast = Reflect.parse("var a = 4 + 7", {builder: builder});

License

MIT X Licensed.

Keywords

FAQs

Package last updated on 27 Jun 2012

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