# reflect

> JavaScript parser adhering to Mozilla's parser API

Latest version **0.1.3** (published 2012-06-27) · 0 weekly downloads

## Install

```sh
npm install reflect
pnpm add reflect
yarn add reflect
bun add reflect
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2012-06-27 |
| First published | 2011-06-16 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.4 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 111 |
| Author | Zach Carter |
| Maintainers | zaach |
| Keywords | parser, ast, reflect, javascript |

## Links

- npm: https://www.npmjs.com/package/reflect
- Repository: https://github.com/zaach/reflect.js
- Issues: http://github.com/zaach/reflect.js/issues
- npm.io page: https://npm.io/package/reflect

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2012-06-27
- 0.1.2 — 2012-06-19
- 0.1.1 — 2012-06-17
- 0.0.7 — 2012-06-06
- 0.0.6 — 2012-06-06
- 0.0.5 — 2011-07-07
- 0.0.4 — 2011-07-06
- 0.0.3 — 2011-06-28
- 0.0.2 — 2011-06-16

## README

![Reflect.js](https://github.com/zaach/reflect.js/raw/master/reflectjs.png "Reflect.js")

Reflect.js is a JavaScript (ES3 compatible) implementation of [Mozilla's Parser API](https://developer.mozilla.org/en/SpiderMonkey/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](http://www.andychu.net/ecmascript/RegExp-Enhancements.html) by Andy Chu.


Download
========
You can download a minified-standalone version of reflect.js to embed in web pages [here](https://raw.github.com/zaach/reflect.js/master/standalone/reflect.js).

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](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.

---
_Source: https://npm.io/package/reflect · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
