Socket
Socket
Sign inDemoInstall

esprima

Package Overview
Dependencies
0
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.9.3 to 0.9.4

comment.patch

177

esprima.js

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

length,
buffer;
buffer,
comments;

@@ -61,2 +62,3 @@ Token = {

CatchClause: 'CatchClause',
Comment: 'Comment',
ConditionalExpression: 'ConditionalExpression',

@@ -633,8 +635,5 @@ ContinueStatement: 'ContinueStatement',

function lex() {
function advance() {
var ch, token;
buffer = null;
skipComment();
if (index >= length) {

@@ -670,2 +669,24 @@ return {

function lex() {
var pos, token;
if (buffer) {
index = buffer.range[1];
lineNumber = buffer.lineNumber;
token = buffer;
buffer = null;
return token;
}
buffer = null;
skipComment();
pos = index;
token = advance();
token.range = [pos, index];
token.lineNumber = lineNumber;
return token;
}
function lookahead() {

@@ -1875,2 +1896,20 @@ var pos, line, token;

function parseSwitchConsequent() {
var consequent = [],
statement;
while (index < length) {
if (match('}') || matchKeyword('default') || matchKeyword('case')) {
break;
}
statement = parseStatement();
if (typeof statement === 'undefined') {
break;
}
consequent.push(statement);
}
return consequent;
}
function parseSwitchStatement() {

@@ -1913,19 +1952,6 @@ var discriminant, cases, test, consequent, statement;

consequent = [];
while (index < length) {
if (match('}') || matchKeyword('default') || matchKeyword('case')) {
break;
}
statement = parseStatement();
if (typeof statement === 'undefined') {
break;
}
consequent.push(statement);
}
cases.push({
type: Syntax.SwitchCase,
test: test,
consequent: consequent
consequent: parseSwitchConsequent()
});

@@ -2232,3 +2258,94 @@ }

exports.parse = function (code) {
// The following functions are needed only when the option to preserve
// the comments is active.
function scanComment() {
var comment, ch, start, blockComment, lineComment;
comment = '';
blockComment = false;
lineComment = false;
while (index < length) {
ch = source[index];
if (lineComment) {
ch = nextChar();
if (isLineTerminator(ch)) {
lineComment = false;
lineNumber += 1;
comments.push({
range: [start, index - 1],
type: 'Line',
value: comment
});
comment = '';
} else {
comment += ch;
}
} else if (blockComment) {
ch = nextChar();
comment += ch;
if (ch === '*') {
ch = source[index];
if (ch === '/') {
comment = comment.substr(0, comment.length - 1);
blockComment = false;
nextChar();
comments.push({
range: [start, index - 1],
type: 'Block',
value: comment
});
comment = '';
}
} else if (isLineTerminator(ch)) {
lineNumber += 1;
}
} else if (ch === '/') {
ch = source[index + 1];
if (ch === '/') {
start = index;
nextChar();
nextChar();
lineComment = true;
} else if (ch === '*') {
start = index;
nextChar();
nextChar();
blockComment = true;
} else {
break;
}
} else if (isWhiteSpace(ch)) {
nextChar();
} else if (isLineTerminator(ch)) {
nextChar();
lineNumber += 1;
} else {
break;
}
}
if (comment.length > 0) {
comments.push({
range: [start, index],
type: (blockComment) ? 'Block' : 'Line',
value: comment
});
}
}
exports.parse = function (code, options) {
var program,
comment = false,
original = {};
if (typeof options !== 'undefined') {
if (typeof options.comment === 'boolean') {
comment = options.comment;
}
}
source = code;

@@ -2239,8 +2356,24 @@ index = 0;

buffer = null;
return parseProgram();
if (comment) {
// Run-time patching.
comments = [];
original.skipComment = skipComment;
skipComment = scanComment;
}
program = parseProgram();
if (comment) {
program.comments = comments;
skipComment = original.skipComment;
comments = [];
}
return program;
};
// Sync with package.json.
exports.version = '0.9.3';
exports.version = '0.9.4';
}(typeof exports === 'undefined' ? (esprima = {}) : exports));

2

package.json

@@ -9,3 +9,3 @@ {

},
"version": "0.9.3",
"version": "0.9.4",
"engines": {

@@ -12,0 +12,0 @@ "node": ">=0.4.0"

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc