espree
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
acorn-jsx | 5.3.2 | 7.46 kB | MIT | prod | |
acorn | 8.11.3 | 122.89 kB | MIT | prod peer | |
eslint-visitor-keys | 3.4.3 | 7.92 kB | Apache-2.0 | prod |
Espree is a JavaScript parser that started as a fork of Esprima v1.2.2 and is built on top of Acorn. It's primary function is to produce output similar to Esprima but with a similar API, making it easy to use in place of Esprima. Espree aims to produce the same Abstract Syntax Tree (AST) structure and tokens as Esprima, with attached comments and additional information on AST nodes.
Espree is easy to install and use. To install it, all you need to do is to run the command npm i espree
in your terminal. Once installed, you can incorporate Espree into your ESM or CommonJS file. For ESM files, you can use it as follows:
import * as espree from "espree";
const ast = espree.parse(code);
And for Common JS files, the usage would be:
const espree = require("espree");
const ast = espree.parse(code);
Espree's parse
and tokenize
functions are key to its functionality. The parse
function allows you to parse the given code and return an abstract syntax tree. On the other hand, tokenize
function can be used to get the tokens of a given code.
The Espree documentation can be found within the project's README on the GitHub repository located at git+https://github.com/eslint/espree.git. Here you can find comprehensive details about various aspects of Espree such as usage, API, options, differences from Espree 2.x, incompatibilities and frequently asked questions. Additional project-related information about contribution guidelines, security policy and build commands is also provided in the README. For detailed options read-up and specific API usage examples, always referring to this official GitHub documentation is best practice for ongoing engagement with Espree.