Socket
Socket
Sign inDemoInstall

esprima

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esprima - npm Package Compare versions

Comparing version 2.1.0 to 2.2.0

10

package.json

@@ -10,3 +10,3 @@ {

},
"version": "2.1.0",
"version": "2.2.0",
"files": [

@@ -17,4 +17,2 @@ "bin",

"test/test.js",
"test/compat.js",
"test/reflect.js",
"esprima.js"

@@ -46,4 +44,4 @@ ],

"devDependencies": {
"eslint": "~0.15.1",
"jscs": "~1.11.3",
"eslint": "~0.19.0",
"jscs": "~1.12.0",
"istanbul": "~0.3.7",

@@ -73,3 +71,3 @@ "escomplex-js": "1.2.0",

"eslint": "node node_modules/eslint/bin/eslint.js esprima.js",
"complexity": "node tools/list-complexity.js && cr -s -l -w --maxcyc 16 esprima.js",
"complexity": "node tools/list-complexity.js && cr -s -l -w --maxcyc 17 esprima.js",

@@ -76,0 +74,0 @@ "coverage": "npm run analyze-coverage && npm run check-coverage",

11

README.md
**Esprima** ([esprima.org](http://esprima.org), BSD license) is a high performance,
standard-compliant [ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
parser written in ECMAScript (also popularly known as
[JavaScript](http://en.wikipedia.org/wiki/JavaScript>JavaScript)).
Esprima is created and maintained by [Ariya Hidayat](http://twitter.com/ariyahidayat),
[JavaScript](https://en.wikipedia.org/wiki/JavaScript).
Esprima is created and maintained by [Ariya Hidayat](https://twitter.com/ariyahidayat),
with the help of [many contributors](https://github.com/jquery/esprima/contributors).

@@ -11,7 +11,6 @@

- Full support for ECMAScript 5.1 ([ECMA-262](http://www.ecma-international.org/publications/standards/Ecma-262.htm))
- Sensible [syntax tree format](http://esprima.org/doc/index.html#ast) compatible with Mozilla
[Parser AST](https://developer.mozilla.org/en/SpiderMonkey/Parser_API)
- Sensible [syntax tree format](https://github.com/estree/estree/blob/master/spec.md) as standardized by [EStree project](https://github.com/estree/estree)
- Optional tracking of syntax node location (index-based and line-column)
- Heavily tested (> 700 [unit tests](http://esprima.org/test/) with [full code coverage](http://esprima.org/test/coverage.html))
- [Partial support](http://esprima.org/doc/es6.html) for ECMAScript 6
- Heavily tested (~1000 [unit tests](https://github.com/jquery/esprima/tree/master/test/fixtures) with [full code coverage](https://travis-ci.org/jquery/esprima))
- [Partial support](https://github.com/jquery/esprima/issues/1099) for ECMAScript 6

@@ -18,0 +17,0 @@ Esprima serves as a **building block** for some JavaScript

@@ -39,3 +39,2 @@ /*

'runner',
'compat',
'parselibs'

@@ -42,0 +41,0 @@ ];

@@ -118,3 +118,4 @@ /*

tolerant: (typeof syntax.errors !== 'undefined'),
source: null
source: null,
sourceType: syntax.sourceType
};

@@ -148,5 +149,5 @@

// Some variations of the options.
tree = esprima.parse(code, { tolerant: options.tolerant });
tree = esprima.parse(code, { tolerant: options.tolerant, range: true });
tree = esprima.parse(code, { tolerant: options.tolerant, loc: true });
tree = esprima.parse(code, { tolerant: options.tolerant, sourceType: options.sourceType });
tree = esprima.parse(code, { tolerant: options.tolerant, sourceType: options.sourceType, range: true });
tree = esprima.parse(code, { tolerant: options.tolerant, sourceType: options.sourceType, loc: true });

@@ -229,2 +230,47 @@ tree = esprima.parse(code, options);

function testModule(esprima, code, exception) {
'use strict';
var i, options, expected, actual, err, handleInvalidRegexFlag, tokenize;
// Different parsing options should give the same error.
options = [
{ sourceType: 'module' },
{ sourceType: 'module', comment: true },
{ sourceType: 'module', raw: true },
{ sourceType: 'module', raw: true, comment: true }
];
if (!exception.message) {
exception.message = 'Error: Line 1: ' + exception.description;
}
exception.description = exception.message.replace(/Error: Line [0-9]+: /, '');
expected = JSON.stringify(exception);
for (i = 0; i < options.length; i += 1) {
try {
esprima.parse(code, options[i]);
} catch (e) {
err = errorToObject(e);
err.description = e.description;
actual = JSON.stringify(err);
}
if (expected !== actual) {
// Compensate for old V8 which does not handle invalid flag.
if (exception.message.indexOf('Invalid regular expression') > 0) {
if (typeof actual === 'undefined' && !handleInvalidRegexFlag) {
return;
}
}
throw new NotMatchingError(expected, actual);
}
}
}
function testError(esprima, code, exception) {

@@ -343,4 +389,4 @@ 'use strict';

var dirs = fs.readdirSync(root), key, kind,
kinds = ['case', 'source', 'run', 'tree', 'tokens', 'failure', 'result'],
suffices = ['js', 'js', 'js', 'json', 'json', 'json', 'json'];
kinds = ['case', 'source', 'module', 'run', 'tree', 'tokens', 'failure', 'result'],
suffices = ['js', 'js', 'json', 'js', 'json', 'json', 'json', 'json'];

@@ -382,3 +428,5 @@ dirs.forEach(function (item) {

try {
if (testCase.hasOwnProperty('tree')) {
if (testCase.hasOwnProperty('module')) {
testModule(esprima, testCase.case, JSON.parse(testCase.module));
} else if (testCase.hasOwnProperty('tree')) {
testParse(esprima, testCase.case, JSON.parse(testCase.tree));

@@ -430,3 +478,4 @@ } else if (testCase.hasOwnProperty('tokens')) {

process.exit(failures.length === 0 ? 0 : 1);
}());
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc