# shift-parser

> ECMAScript parser that produces a Shift format AST

Latest version **8.0.0** (published 2022-04-27) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install shift-parser
pnpm add shift-parser
yarn add shift-parser
bun add shift-parser
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 8.0.0 |
| Published | 2022-04-27 |
| First published | 2014-12-18 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 224.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 259 |
| Author | Shape Security |
| Maintainers | michaelficarra, bakkot, shapesecurity |
| Keywords | Shift, AST, node, parser, SpiderMonkey, Parser, API, parse, spider, monkey, abstract, syntax, tree |

## Links

- npm: https://www.npmjs.com/package/shift-parser
- Repository: https://github.com/shapesecurity/shift-parser-js
- Issues: https://github.com/shapesecurity/shift-parser-js/issues
- npm.io page: https://npm.io/package/shift-parser

## Dependencies (4)

- [multimap](https://npm.io/package/multimap.md) ^1.0.2
- [shift-ast](https://npm.io/package/shift-ast.md) 7.0.0
- [shift-reducer](https://npm.io/package/shift-reducer.md) 7.0.0
- [shift-regexp-acceptor](https://npm.io/package/shift-regexp-acceptor.md) 3.0.0

## 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

- 8.0.0 (latest) — 2022-04-27
- 7.0.3 — 2020-06-12
- 7.0.1 — 2020-06-08
- 7.0.0 — 2019-05-29
- 6.0.1 — 2019-01-23
- 6.0.0 — 2018-12-13
- 5.2.4 — 2018-04-03
- 5.2.3 — 2017-11-01
- 5.2.2 — 2017-10-10
- 5.2.1 — 2017-09-22
- 5.2.0 — 2017-09-15
- 5.0.7 — 2017-06-12
- 5.0.6 — 2017-04-20
- 5.0.5 — 2017-04-12
- 5.0.4 — 2017-03-21
- … 21 more at https://npm.io/package/shift-parser/versions

## README

Shift Parser
============


## About

This module provides an [ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
parser that produces a [Shift format](https://github.com/shapesecurity/shift-spec) AST.


## Status

[Stable](http://nodejs.org/api/documentation.html#documentation_stability_index).

The parser supports version 6 (release candidate 2) of the ECMA-262 standard.


## Installation

```sh
npm install shift-parser
```


## Usage

```es6
import parse from "shift-parser";
let ast = parse("/* ECMAScript program text */");
```

```es6
import {parseScript, parseModule} from "shift-parser";
let scriptAST = parseScript("/* ECMAScript Script text */");
let moduleAST = parseModule("/* ECMAScript Module text */");
```

Or in node.js:

```js
var parseScript = require("shift-parser").parseScript;
var scriptAST = parseScript("/* ECMAScript Script text */");
```


Location information is available in environments which support `WeakMap` via an alternative interface:

```js
let {parseScriptWithLocation, parseModuleWithLocation} = require("shift-parser");
let {tree, locations, comments} = parseScriptWithLocation("2 + 3 /* = 5 */");
let threeNode = tree.statements[0].expression.right;
locations.get(threeNode); // { start: { line: 1, column: 4, offset: 4 }, end: { line: 1, column: 5, offset: 5 } }
comments; // [ { text: ' = 5 ', type: 'MultiLine', start: { line: 1, column: 6, offset: 6 }, end: { line: 1, column: 15, offset: 15 } } ]
```


## Contributing

* Open a Github issue with a description of your desired change. If one exists already, leave a message stating that you are working on it with the date you expect it to be complete.
* Fork this repo, and clone the forked repo.
* Install dependencies with `npm install`.
* Build and test in your environment with `npm run build && npm test`.
* Create a feature branch. Make your changes. Add tests.
* Build and test in your environment with `npm run build && npm test`.
* Make a commit that includes the text "fixes #*XX*" where *XX* is the Github issue.
* Open a Pull Request on Github.


## License

    Copyright 2014 Shape Security, Inc.

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

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