Socket
Socket
Sign inDemoInstall

reflect

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.5 to 0.0.6

dist/stringify.js

9

dist/reflect.js
var parser = require("./parser").parser,
nodes = require("./nodes");
nodes = require("./nodes"),
stringify = require("./stringify").stringify;

@@ -102,5 +103,9 @@ function JSParser (options) {

return new JSParser(options).parse(src);
}
},
stringify: stringify
};
exports.parse = exports.Reflect.parse;
exports.stringify = stringify;
exports.builder = builder;

@@ -5,5 +5,6 @@ {

"description": "JavaScript parser adhering to Mozilla's parser API",
"version": "0.0.5",
"version": "0.0.6",
"keywords": [
"parser",
"ast",
"reflect",

@@ -21,3 +22,3 @@ "javascript"

"engines": {
"node": "0.4 || 0.5"
"node": ">= 0.4"
},

@@ -29,5 +30,5 @@ "devDependencies": {

"scripts": {
"test": "node test/reflect-parse.js"
"test": "node test/all-tests.js"
},
"dependencies": {}
}
}

@@ -6,3 +6,3 @@ ![Reflect.js](https://github.com/zaach/reflect.js/raw/master/reflectjs.png "Reflect.js")

Parsing large files can be slow, for reasons [articulated](http://www.andychu.net/ecmascript/RegExp-Enhancements.html) by Andy Chu.
Parsing really large files can be slow, for reasons [articulated](http://www.andychu.net/ecmascript/RegExp-Enhancements.html) by Andy Chu.

@@ -20,4 +20,29 @@

Use
=======
var Reflect = require('reflect');
var ast = Reflect.parse("var a = 4 + 7");
console.log(Reflect.stringify(ast, " "));
Refer to [Mozilla's docs](https://developer.mozilla.org/en/SpiderMonkey/Parser_API) for details on the AST interface.
Builders
=======
The optional [builder](https://developer.mozilla.org/en/SpiderMonkey/Parser_API#Builder_objects) 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](https://raw.github.com/zaach/reflect.js/master/lib/nodes.js) 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.

@@ -25,2 +25,3 @@ // Bundles the built code base as a standalone javascript file

"parser.js": "dist/parser.js",
"stringify.js": "dist/stringify.js",
"nodes.js": "dist/nodes.js"

@@ -27,0 +28,0 @@ };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc