acorn-6to5
Advanced tools
Comparing version 0.11.1-18 to 0.11.1-19
@@ -69,2 +69,4 @@ // Acorn: Loose parser | ||
token = ahead.shift() || readToken(forceRegexp); | ||
if (options.onToken) | ||
options.onToken(token); | ||
@@ -105,4 +107,6 @@ if (token.start >= nextLineStart) { | ||
replace = {start: e.pos, end: pos, | ||
type: input.charAt(e.pos) == "`" ? tt.template : tt.templateContinued, | ||
value: input.slice(e.pos + 1, pos)}; | ||
type: tt.template, | ||
value: input.slice(e.pos, pos)}; | ||
} else if (/comment/.test(msg)) { | ||
replace = fetchToken.current(); | ||
} else { | ||
@@ -258,10 +262,2 @@ replace = false; | ||
function finishNodeAt(node, type, pos) { | ||
if (options.locations) { node.loc.end = pos[1]; pos = pos[0]; } | ||
node.type = type; | ||
node.end = pos; | ||
if (options.ranges) node.range[1] = pos; | ||
return node; | ||
} | ||
function dummyIdent() { | ||
@@ -310,2 +306,3 @@ var dummy = startNode(); | ||
case "SpreadElement": | ||
case "AssignmentPattern": | ||
return expr; | ||
@@ -632,10 +629,3 @@ | ||
if (token.type.prefix) { | ||
var node = startNode(), update = token.type.isUpdate, nodeType; | ||
if (token.type === tt.ellipsis) { | ||
nodeType = "SpreadElement"; | ||
} else { | ||
nodeType = update ? "UpdateExpression" : "UnaryExpression"; | ||
node.operator = token.value; | ||
node.prefix = true; | ||
} | ||
var node = startNode(), update = token.type.isUpdate; | ||
node.operator = token.value; | ||
@@ -646,3 +636,8 @@ node.prefix = true; | ||
if (update) node.argument = checkLVal(node.argument); | ||
return finishNode(node, nodeType); | ||
return finishNode(node, update ? "UpdateExpression" : "UnaryExpression"); | ||
} else if (token.type === tt.ellipsis) { | ||
var node = startNode(); | ||
next(); | ||
node.argument = parseMaybeUnary(noIn); | ||
return finishNode(node, "SpreadElement"); | ||
} | ||
@@ -701,3 +696,3 @@ var start = storeCurrentPos(); | ||
base = finishNode(node, "CallExpression"); | ||
} else if (token.type == tt.template) { | ||
} else if (token.type == tt.backQuote) { | ||
var node = startNodeAt(start); | ||
@@ -795,3 +790,3 @@ node.tag = base; | ||
case tt.template: | ||
case tt.backQuote: | ||
return parseTemplate(); | ||
@@ -819,9 +814,10 @@ | ||
function parseTemplateElement() { | ||
var elem = startNodeAt(options.locations ? [token.start + 1, token.startLoc.offset(1)] : token.start + 1); | ||
elem.value = token.value; | ||
elem.tail = input.charCodeAt(token.end - 1) !== 123; // '{' | ||
var endOff = elem.tail ? 1 : 2; | ||
var endPos = options.locations ? [token.end - endOff, token.endLoc.offset(-endOff)] : token.end - endOff; | ||
var elem = startNode(); | ||
elem.value = { | ||
raw: input.slice(token.start, token.end), | ||
cooked: token.value | ||
}; | ||
next(); | ||
return finishNodeAt(elem, "TemplateElement", endPos); | ||
elem.tail = token.type === tt.backQuote; | ||
return finishNode(elem, "TemplateElement"); | ||
} | ||
@@ -831,2 +827,3 @@ | ||
var node = startNode(); | ||
next(); | ||
node.expressions = []; | ||
@@ -836,17 +833,14 @@ var curElt = parseTemplateElement(); | ||
while (!curElt.tail) { | ||
var next = parseExpression(); | ||
if (isDummy(next)) { | ||
node.quasis[node.quasis.length - 1].tail = true; | ||
break; | ||
} | ||
node.expressions.push(next); | ||
if (token.type === tt.templateContinued) { | ||
node.quasis.push(curElt = parseTemplateElement()); | ||
next(); | ||
node.expressions.push(parseExpression()); | ||
if (expect(tt.braceR)) { | ||
curElt = parseTemplateElement(); | ||
} else { | ||
curElt = startNode(); | ||
curElt.value = {cooked: "", raw: ""}; | ||
curElt.value = {cooked: '', raw: ''}; | ||
curElt.tail = true; | ||
node.quasis.push(curElt); | ||
} | ||
node.quasis.push(curElt); | ||
} | ||
expect(tt.backQuote); | ||
return finishNode(node, "TemplateLiteral"); | ||
@@ -872,6 +866,7 @@ } | ||
while (!closes(tt.braceR, indent, line)) { | ||
if (isClass && semicolon()) continue; | ||
var prop = startNode(), isGenerator; | ||
if (options.ecmaVersion >= 6) { | ||
if (isClass) { | ||
if (prop['static'] = (token.type === tt.name && token.value === "static")) next(); | ||
prop['static'] = false; | ||
} else { | ||
@@ -885,2 +880,12 @@ prop.method = false; | ||
if (isDummy(prop.key)) { if (isDummy(parseExpression(true))) next(); eat(tt.comma); continue; } | ||
if (isClass) { | ||
if (prop.key.type === "Identifier" && !prop.computed && prop.key.name === "static" && | ||
(token.type != tt.parenL && token.type != tt.braceL)) { | ||
prop['static'] = true; | ||
isGenerator = eat(tt.star); | ||
parsePropertyName(prop); | ||
} else { | ||
prop['static'] = false; | ||
} | ||
} | ||
if (!isClass && eat(tt.colon)) { | ||
@@ -898,3 +903,3 @@ prop.kind = "init"; | ||
} else if (options.ecmaVersion >= 5 && prop.key.type === "Identifier" && | ||
(prop.key.name === "get" || prop.key.name === "set") && | ||
!prop.computed && (prop.key.name === "get" || prop.key.name === "set") && | ||
(token.type != tt.comma && token.type != tt.braceR)) { | ||
@@ -915,3 +920,2 @@ prop.kind = prop.key.name; | ||
node.body.body.push(finishNode(prop, "MethodDefinition")); | ||
semicolon(); | ||
} else { | ||
@@ -960,3 +964,2 @@ node.properties.push(finishNode(prop, "Property")); | ||
node.name = token.type === tt.name ? token.value : token.type.keyword; | ||
fetchToken.noRegexp(); | ||
next(); | ||
@@ -963,0 +966,0 @@ return finishNode(node, "Identifier"); |
@@ -5,3 +5,3 @@ { | ||
"main": "acorn_csp.js", | ||
"version": "0.11.1-18", | ||
"version": "0.11.1-19", | ||
"maintainers": [ | ||
@@ -24,3 +24,3 @@ { | ||
], | ||
"repository": "https://github.com/sebmck/acorn-6to5", | ||
"repository": "https://github.com/6to5/acorn-6to5", | ||
"licenses": [ | ||
@@ -27,0 +27,0 @@ { |
@@ -288,3 +288,11 @@ // AST walker module for Mozilla Parser API compatible trees | ||
}; | ||
base.Identifier = base.Literal = base.ExportDeclaration = base.ImportDeclaration = ignore; | ||
base.ExportDeclaration = function (node, st, c) { | ||
c(node.declaration, st); | ||
}; | ||
base.ImportDeclaration = function (node, st, c) { | ||
node.specifiers.forEach(function (specifier) { | ||
c(specifier, st); | ||
}); | ||
}; | ||
base.ImportSpecifier = base.ImportBatchSpecifier = base.Identifier = base.Literal = ignore; | ||
@@ -291,0 +299,0 @@ base.TaggedTemplateExpression = function(node, st, c) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
355940
18
9708