reflect
Advanced tools
Comparing version 0.0.5 to 0.0.6
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses eval() which is a dangerous function. This prevents the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
384256
16
4807
47
0
2