esprima (4.0.1)
Published 2026-02-24 13:56:21 +00:00 by atheaadmin
Installation
registry=npm install esprima@4.0.1"esprima": "4.0.1"About this package
Esprima (esprima.org, BSD license) is a high performance, standard-compliant ECMAScript parser written in ECMAScript (also popularly known as JavaScript). Esprima is created and maintained by Ariya Hidayat, with the help of many contributors.
Features
- Full support for ECMAScript 2017 (ECMA-262 8th Edition)
- Sensible syntax tree format as standardized by ESTree project
- Experimental support for JSX, a syntax extension for React
- Optional tracking of syntax node location (index-based and line-column)
- Heavily tested (~1500 unit tests with full code coverage)
API
Esprima can be used to perform lexical analysis (tokenization) or syntactic analysis (parsing) of a JavaScript program.
A simple example on Node.js REPL:
> var esprima = require('esprima');
> var program = 'const answer = 42';
> esprima.tokenize(program);
[ { type: 'Keyword', value: 'const' },
{ type: 'Identifier', value: 'answer' },
{ type: 'Punctuator', value: '=' },
{ type: 'Numeric', value: '42' } ]
> esprima.parseScript(program);
{ type: 'Program',
body:
[ { type: 'VariableDeclaration',
declarations: [Object],
kind: 'const' } ],
sourceType: 'script' }
For more information, please read the complete documentation.
Dependencies
Development Dependencies
| ID | Version |
|---|---|
| codecov.io | ~0.1.6 |
| escomplex-js | 1.2.0 |
| everything.js | ~1.0.3 |
| glob | ~7.1.0 |
| istanbul | ~0.4.0 |
| json-diff | ~0.3.1 |
| karma | ~1.3.0 |
| karma-chrome-launcher | ~2.0.0 |
| karma-detect-browsers | ~2.2.3 |
| karma-edge-launcher | ~0.2.0 |
| karma-firefox-launcher | ~1.0.0 |
| karma-ie-launcher | ~1.0.0 |
| karma-mocha | ~1.3.0 |
| karma-safari-launcher | ~1.0.0 |
| karma-safaritechpreview-launcher | ~0.0.4 |
| karma-sauce-launcher | ~1.1.0 |
| lodash | ~3.10.1 |
| mocha | ~3.2.0 |
| node-tick-processor | ~0.0.2 |
| regenerate | ~1.3.2 |
| temp | ~0.8.3 |
| tslint | ~5.1.0 |
| typescript | ~2.3.2 |
| typescript-formatter | ~5.1.3 |
| unicode-8.0.0 | ~0.7.0 |
| webpack | ~1.14.0 |
Keywords
ast
ecmascript
esprima
javascript
parser
syntax
Details
Assets (1)
Versions (2)
View all
esprima-4.0.1.tgz
51 KiB