Comparing version 5.5.3 to 5.6.0
@@ -11,8 +11,7 @@ const fs = require("fs") | ||
"class-fields-public", | ||
"numeric-separator-literal", | ||
"optional-catch-binding" | ||
"numeric-separator-literal" | ||
]; | ||
run( | ||
(content, {sourceType}) => parse(content, {sourceType, ecmaVersion: 9}), | ||
(content, {sourceType}) => parse(content, {sourceType, ecmaVersion: 10}), | ||
{ | ||
@@ -19,0 +18,0 @@ testsDirectory: path.dirname(require.resolve("test262/package.json")), |
@@ -1,12 +0,20 @@ | ||
## 5.5.3 (2018-03-08) | ||
## 5.6.0 (2018-05-31) | ||
### Bug fixes | ||
A _second_ republish of the code in 5.5.1, this time with yarn, to hopefully get valid timestamps. | ||
Fix a bug in the walker that caused a crash when walking an object pattern spread. | ||
## 5.5.2 (2018-03-08) | ||
### New features | ||
Allow U+2028 and U+2029 in string when ECMAVersion >= 10. | ||
Allow binding-less catch statements when ECMAVersion >= 10. | ||
Add `allowAwaitOutsideFunction` option for parsing top-level `await`. | ||
## 5.5.3 (2018-03-08) | ||
### Bug fixes | ||
A republish of the code in 5.5.1 in an attempt to solve an issue with the file timestamps in the npm package being 0. | ||
A _second_ republish of the code in 5.5.1, this time with yarn, to hopefully get valid timestamps. | ||
@@ -13,0 +21,0 @@ ## 5.5.2 (2018-03-08) |
@@ -27,2 +27,3 @@ import { Node, SourceLocation, Token, addLooseExports, defaultOptions, getLineInfo, isNewLine, lineBreak, lineBreakG, tokTypes, tokenizer } from './acorn.es'; | ||
this.inAsync = false; | ||
this.inFunction = false; | ||
// Load plugins | ||
@@ -440,5 +441,8 @@ this.options.pluginsLoose = options.pluginsLoose || {}; | ||
this.next(); | ||
this.expect(tokTypes.parenL); | ||
clause.param = this.toAssignable(this.parseExprAtom(), true); | ||
this.expect(tokTypes.parenR); | ||
if (this.eat(tokTypes.parenL)) { | ||
clause.param = this.toAssignable(this.parseExprAtom(), true); | ||
this.expect(tokTypes.parenR); | ||
} else { | ||
clause.param = null; | ||
} | ||
clause.body = this.parseBlock(); | ||
@@ -637,3 +641,3 @@ node.handler = this.finishNode(clause, "CatchClause"); | ||
lp$1.parseFunction = function(node, isStatement, isAsync) { | ||
var oldInAsync = this.inAsync; | ||
var oldInAsync = this.inAsync, oldInFunction = this.inFunction; | ||
this.initFunction(node); | ||
@@ -649,2 +653,3 @@ if (this.options.ecmaVersion >= 6) { | ||
this.inAsync = node.async; | ||
this.inFunction = true; | ||
node.params = this.parseFunctionParams(); | ||
@@ -654,2 +659,3 @@ node.body = this.parseBlock(); | ||
this.inAsync = oldInAsync; | ||
this.inFunction = oldInFunction; | ||
return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression") | ||
@@ -887,3 +893,5 @@ }; | ||
var start = this.storeCurrentPos(), expr; | ||
if (this.options.ecmaVersion >= 8 && this.inAsync && this.toks.isContextual("await")) { | ||
if (this.options.ecmaVersion >= 8 && this.toks.isContextual("await") && | ||
(this.inAsync || (!this.inFunction && this.options.allowAwaitOutsideFunction)) | ||
) { | ||
expr = this.parseAwait(); | ||
@@ -1309,3 +1317,3 @@ sawUnary = true; | ||
lp$2.parseMethod = function(isGenerator, isAsync) { | ||
var node = this.startNode(), oldInAsync = this.inAsync; | ||
var node = this.startNode(), oldInAsync = this.inAsync, oldInFunction = this.inFunction; | ||
this.initFunction(node); | ||
@@ -1317,2 +1325,3 @@ if (this.options.ecmaVersion >= 6) | ||
this.inAsync = node.async; | ||
this.inFunction = true; | ||
node.params = this.parseFunctionParams(); | ||
@@ -1322,2 +1331,3 @@ node.body = this.parseBlock(); | ||
this.inAsync = oldInAsync; | ||
this.inFunction = oldInFunction; | ||
return this.finishNode(node, "FunctionExpression") | ||
@@ -1327,3 +1337,3 @@ }; | ||
lp$2.parseArrowExpression = function(node, params, isAsync) { | ||
var oldInAsync = this.inAsync; | ||
var oldInAsync = this.inAsync, oldInFunction = this.inFunction; | ||
this.initFunction(node); | ||
@@ -1333,2 +1343,3 @@ if (this.options.ecmaVersion >= 8) | ||
this.inAsync = node.async; | ||
this.inFunction = true; | ||
node.params = this.toAssignableList(params, true); | ||
@@ -1343,2 +1354,3 @@ node.expression = this.tok.type !== tokTypes.braceL; | ||
this.inAsync = oldInAsync; | ||
this.inFunction = oldInFunction; | ||
return this.finishNode(node, "ArrowFunctionExpression") | ||
@@ -1345,0 +1357,0 @@ }; |
@@ -31,2 +31,3 @@ (function (global, factory) { | ||
this.inAsync = false; | ||
this.inFunction = false; | ||
// Load plugins | ||
@@ -444,5 +445,8 @@ this.options.pluginsLoose = options.pluginsLoose || {}; | ||
this.next(); | ||
this.expect(__acorn.tokTypes.parenL); | ||
clause.param = this.toAssignable(this.parseExprAtom(), true); | ||
this.expect(__acorn.tokTypes.parenR); | ||
if (this.eat(__acorn.tokTypes.parenL)) { | ||
clause.param = this.toAssignable(this.parseExprAtom(), true); | ||
this.expect(__acorn.tokTypes.parenR); | ||
} else { | ||
clause.param = null; | ||
} | ||
clause.body = this.parseBlock(); | ||
@@ -641,3 +645,3 @@ node.handler = this.finishNode(clause, "CatchClause"); | ||
lp$1.parseFunction = function(node, isStatement, isAsync) { | ||
var oldInAsync = this.inAsync; | ||
var oldInAsync = this.inAsync, oldInFunction = this.inFunction; | ||
this.initFunction(node); | ||
@@ -653,2 +657,3 @@ if (this.options.ecmaVersion >= 6) { | ||
this.inAsync = node.async; | ||
this.inFunction = true; | ||
node.params = this.parseFunctionParams(); | ||
@@ -658,2 +663,3 @@ node.body = this.parseBlock(); | ||
this.inAsync = oldInAsync; | ||
this.inFunction = oldInFunction; | ||
return this.finishNode(node, isStatement ? "FunctionDeclaration" : "FunctionExpression") | ||
@@ -891,3 +897,5 @@ }; | ||
var start = this.storeCurrentPos(), expr; | ||
if (this.options.ecmaVersion >= 8 && this.inAsync && this.toks.isContextual("await")) { | ||
if (this.options.ecmaVersion >= 8 && this.toks.isContextual("await") && | ||
(this.inAsync || (!this.inFunction && this.options.allowAwaitOutsideFunction)) | ||
) { | ||
expr = this.parseAwait(); | ||
@@ -1313,3 +1321,3 @@ sawUnary = true; | ||
lp$2.parseMethod = function(isGenerator, isAsync) { | ||
var node = this.startNode(), oldInAsync = this.inAsync; | ||
var node = this.startNode(), oldInAsync = this.inAsync, oldInFunction = this.inFunction; | ||
this.initFunction(node); | ||
@@ -1321,2 +1329,3 @@ if (this.options.ecmaVersion >= 6) | ||
this.inAsync = node.async; | ||
this.inFunction = true; | ||
node.params = this.parseFunctionParams(); | ||
@@ -1326,2 +1335,3 @@ node.body = this.parseBlock(); | ||
this.inAsync = oldInAsync; | ||
this.inFunction = oldInFunction; | ||
return this.finishNode(node, "FunctionExpression") | ||
@@ -1331,3 +1341,3 @@ }; | ||
lp$2.parseArrowExpression = function(node, params, isAsync) { | ||
var oldInAsync = this.inAsync; | ||
var oldInAsync = this.inAsync, oldInFunction = this.inFunction; | ||
this.initFunction(node); | ||
@@ -1337,2 +1347,3 @@ if (this.options.ecmaVersion >= 8) | ||
this.inAsync = node.async; | ||
this.inFunction = true; | ||
node.params = this.toAssignableList(params, true); | ||
@@ -1347,2 +1358,3 @@ node.expression = this.tok.type !== __acorn.tokTypes.braceL; | ||
this.inAsync = oldInAsync; | ||
this.inFunction = oldInFunction; | ||
return this.finishNode(node, "ArrowFunctionExpression") | ||
@@ -1349,0 +1361,0 @@ }; |
@@ -19,7 +19,8 @@ // AST walker module for Mozilla Parser API compatible trees | ||
function simple(node, visitors, base, state, override) { | ||
if (!base) { base = exports.base | ||
; }(function c(node, st, override) { | ||
function simple(node, visitors, baseVisitor, state, override) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
(function c(node, st, override) { | ||
var type = override || node.type, found = visitors[type]; | ||
base[type](node, st, c); | ||
baseVisitor[type](node, st, c); | ||
if (found) { found(node, st); } | ||
@@ -32,4 +33,5 @@ })(node, state, override); | ||
// (and also as state parameter when no other state is present). | ||
function ancestor(node, visitors, base, state) { | ||
if (!base) { base = exports.base; } | ||
function ancestor(node, visitors, baseVisitor, state) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
var ancestors = [];(function c(node, st, override) { | ||
@@ -39,3 +41,3 @@ var type = override || node.type, found = visitors[type]; | ||
if (isNew) { ancestors.push(node); } | ||
base[type](node, st, c); | ||
baseVisitor[type](node, st, c); | ||
if (found) { found(node, st || ancestors, ancestors); } | ||
@@ -51,4 +53,4 @@ if (isNew) { ancestors.pop(); } | ||
// nodes). | ||
function recursive(node, state, funcs, base, override) { | ||
var visitor = funcs ? exports.make(funcs, base) : base;(function c(node, st, override) { | ||
function recursive(node, state, funcs, baseVisitor, override) { | ||
var visitor = funcs ? exports.make(funcs, baseVisitor) : baseVisitor;(function c(node, st, override) { | ||
visitor[override || node.type](node, st, c); | ||
@@ -70,7 +72,8 @@ })(node, state, override); | ||
// A full walk triggers the callback on each node | ||
function full(node, callback, base, state, override) { | ||
if (!base) { base = exports.base | ||
; }(function c(node, st, override) { | ||
function full(node, callback, baseVisitor, state, override) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
(function c(node, st, override) { | ||
var type = override || node.type; | ||
base[type](node, st, c); | ||
baseVisitor[type](node, st, c); | ||
if (!override) { callback(node, st, type); } | ||
@@ -82,4 +85,5 @@ })(node, state, override); | ||
// the callback on each node | ||
function fullAncestor(node, callback, base, state) { | ||
if (!base) { base = exports.base; } | ||
function fullAncestor(node, callback, baseVisitor, state) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
var ancestors = [];(function c(node, st, override) { | ||
@@ -89,3 +93,3 @@ var type = override || node.type; | ||
if (isNew) { ancestors.push(node); } | ||
base[type](node, st, c); | ||
baseVisitor[type](node, st, c); | ||
if (!override) { callback(node, st || ancestors, ancestors, type); } | ||
@@ -99,5 +103,6 @@ if (isNew) { ancestors.pop(); } | ||
// undefined when it doesn't find a matching node. | ||
function findNodeAt(node, start, end, test, base, state) { | ||
function findNodeAt(node, start, end, test, baseVisitor, state) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
test = makeTest(test); | ||
if (!base) { base = exports.base; } | ||
try { | ||
@@ -108,3 +113,3 @@ (function c(node, st, override) { | ||
(end == null || node.end >= end)) | ||
{ base[type](node, st, c); } | ||
{ baseVisitor[type](node, st, c); } | ||
if ((start == null || node.start == start) && | ||
@@ -123,5 +128,6 @@ (end == null || node.end == end) && | ||
// position. Interface similar to findNodeAt. | ||
function findNodeAround(node, pos, test, base, state) { | ||
function findNodeAround(node, pos, test, baseVisitor, state) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
test = makeTest(test); | ||
if (!base) { base = exports.base; } | ||
try { | ||
@@ -131,3 +137,3 @@ (function c(node, st, override) { | ||
if (node.start > pos || node.end < pos) { return } | ||
base[type](node, st, c); | ||
baseVisitor[type](node, st, c); | ||
if (test(type, node)) { throw new Found(node, st) } | ||
@@ -142,5 +148,6 @@ })(node, state); | ||
// Find the outermost matching node after a given position. | ||
function findNodeAfter(node, pos, test, base, state) { | ||
function findNodeAfter(node, pos, test, baseVisitor, state) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
test = makeTest(test); | ||
if (!base) { base = exports.base; } | ||
try { | ||
@@ -151,3 +158,3 @@ (function c(node, st, override) { | ||
if (node.start >= pos && test(type, node)) { throw new Found(node, st) } | ||
base[type](node, st, c); | ||
baseVisitor[type](node, st, c); | ||
})(node, state); | ||
@@ -161,5 +168,6 @@ } catch (e) { | ||
// Find the outermost matching node before a given position. | ||
function findNodeBefore(node, pos, test, base, state) { | ||
function findNodeBefore(node, pos, test, baseVisitor, state) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
test = makeTest(test); | ||
if (!base) { base = exports.base; } | ||
var max;(function c(node, st, override) { | ||
@@ -170,3 +178,3 @@ if (node.start > pos) { return } | ||
{ max = new Found(node, st); } | ||
base[type](node, st, c); | ||
baseVisitor[type](node, st, c); | ||
})(node, state); | ||
@@ -185,5 +193,6 @@ return max | ||
// type properties with the defaults. | ||
function make(funcs, base) { | ||
if (!base) { base = exports.base; } | ||
var visitor = create(base); | ||
function make(funcs, baseVisitor) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
var visitor = create(baseVisitor); | ||
for (var type in funcs) { visitor[type] = funcs[type]; } | ||
@@ -332,4 +341,8 @@ return visitor | ||
if (prop.computed) { c(prop.key, st, "Expression"); } | ||
c(prop.value, st, "Pattern"); | ||
if (prop.type === "Property") { | ||
if (prop.computed) { c(prop.key, st, "Expression"); } | ||
c(prop.value, st, "Pattern"); | ||
} else if (prop.type === "RestElement") { | ||
c(prop.argument, st, "Pattern"); | ||
} | ||
} | ||
@@ -336,0 +349,0 @@ }; |
@@ -25,7 +25,8 @@ (function (global, factory) { | ||
function simple(node, visitors, base, state, override) { | ||
if (!base) { base = exports.base | ||
; }(function c(node, st, override) { | ||
function simple(node, visitors, baseVisitor, state, override) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
(function c(node, st, override) { | ||
var type = override || node.type, found = visitors[type]; | ||
base[type](node, st, c); | ||
baseVisitor[type](node, st, c); | ||
if (found) { found(node, st); } | ||
@@ -38,4 +39,5 @@ })(node, state, override); | ||
// (and also as state parameter when no other state is present). | ||
function ancestor(node, visitors, base, state) { | ||
if (!base) { base = exports.base; } | ||
function ancestor(node, visitors, baseVisitor, state) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
var ancestors = [];(function c(node, st, override) { | ||
@@ -45,3 +47,3 @@ var type = override || node.type, found = visitors[type]; | ||
if (isNew) { ancestors.push(node); } | ||
base[type](node, st, c); | ||
baseVisitor[type](node, st, c); | ||
if (found) { found(node, st || ancestors, ancestors); } | ||
@@ -57,4 +59,4 @@ if (isNew) { ancestors.pop(); } | ||
// nodes). | ||
function recursive(node, state, funcs, base, override) { | ||
var visitor = funcs ? exports.make(funcs, base) : base;(function c(node, st, override) { | ||
function recursive(node, state, funcs, baseVisitor, override) { | ||
var visitor = funcs ? exports.make(funcs, baseVisitor) : baseVisitor;(function c(node, st, override) { | ||
visitor[override || node.type](node, st, c); | ||
@@ -76,7 +78,8 @@ })(node, state, override); | ||
// A full walk triggers the callback on each node | ||
function full(node, callback, base, state, override) { | ||
if (!base) { base = exports.base | ||
; }(function c(node, st, override) { | ||
function full(node, callback, baseVisitor, state, override) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
(function c(node, st, override) { | ||
var type = override || node.type; | ||
base[type](node, st, c); | ||
baseVisitor[type](node, st, c); | ||
if (!override) { callback(node, st, type); } | ||
@@ -88,4 +91,5 @@ })(node, state, override); | ||
// the callback on each node | ||
function fullAncestor(node, callback, base, state) { | ||
if (!base) { base = exports.base; } | ||
function fullAncestor(node, callback, baseVisitor, state) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
var ancestors = [];(function c(node, st, override) { | ||
@@ -95,3 +99,3 @@ var type = override || node.type; | ||
if (isNew) { ancestors.push(node); } | ||
base[type](node, st, c); | ||
baseVisitor[type](node, st, c); | ||
if (!override) { callback(node, st || ancestors, ancestors, type); } | ||
@@ -105,5 +109,6 @@ if (isNew) { ancestors.pop(); } | ||
// undefined when it doesn't find a matching node. | ||
function findNodeAt(node, start, end, test, base, state) { | ||
function findNodeAt(node, start, end, test, baseVisitor, state) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
test = makeTest(test); | ||
if (!base) { base = exports.base; } | ||
try { | ||
@@ -114,3 +119,3 @@ (function c(node, st, override) { | ||
(end == null || node.end >= end)) | ||
{ base[type](node, st, c); } | ||
{ baseVisitor[type](node, st, c); } | ||
if ((start == null || node.start == start) && | ||
@@ -129,5 +134,6 @@ (end == null || node.end == end) && | ||
// position. Interface similar to findNodeAt. | ||
function findNodeAround(node, pos, test, base, state) { | ||
function findNodeAround(node, pos, test, baseVisitor, state) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
test = makeTest(test); | ||
if (!base) { base = exports.base; } | ||
try { | ||
@@ -137,3 +143,3 @@ (function c(node, st, override) { | ||
if (node.start > pos || node.end < pos) { return } | ||
base[type](node, st, c); | ||
baseVisitor[type](node, st, c); | ||
if (test(type, node)) { throw new Found(node, st) } | ||
@@ -148,5 +154,6 @@ })(node, state); | ||
// Find the outermost matching node after a given position. | ||
function findNodeAfter(node, pos, test, base, state) { | ||
function findNodeAfter(node, pos, test, baseVisitor, state) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
test = makeTest(test); | ||
if (!base) { base = exports.base; } | ||
try { | ||
@@ -157,3 +164,3 @@ (function c(node, st, override) { | ||
if (node.start >= pos && test(type, node)) { throw new Found(node, st) } | ||
base[type](node, st, c); | ||
baseVisitor[type](node, st, c); | ||
})(node, state); | ||
@@ -167,5 +174,6 @@ } catch (e) { | ||
// Find the outermost matching node before a given position. | ||
function findNodeBefore(node, pos, test, base, state) { | ||
function findNodeBefore(node, pos, test, baseVisitor, state) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
test = makeTest(test); | ||
if (!base) { base = exports.base; } | ||
var max;(function c(node, st, override) { | ||
@@ -176,3 +184,3 @@ if (node.start > pos) { return } | ||
{ max = new Found(node, st); } | ||
base[type](node, st, c); | ||
baseVisitor[type](node, st, c); | ||
})(node, state); | ||
@@ -191,5 +199,6 @@ return max | ||
// type properties with the defaults. | ||
function make(funcs, base) { | ||
if (!base) { base = exports.base; } | ||
var visitor = create(base); | ||
function make(funcs, baseVisitor) { | ||
if ( baseVisitor === void 0 ) baseVisitor = base; | ||
var visitor = create(baseVisitor); | ||
for (var type in funcs) { visitor[type] = funcs[type]; } | ||
@@ -338,4 +347,8 @@ return visitor | ||
if (prop.computed) { c(prop.key, st, "Expression"); } | ||
c(prop.value, st, "Pattern"); | ||
if (prop.type === "Property") { | ||
if (prop.computed) { c(prop.key, st, "Expression"); } | ||
c(prop.value, st, "Pattern"); | ||
} else if (prop.type === "RestElement") { | ||
c(prop.argument, st, "Pattern"); | ||
} | ||
} | ||
@@ -342,0 +355,0 @@ }; |
@@ -7,3 +7,3 @@ { | ||
"module": "dist/acorn.es.js", | ||
"version": "5.5.3", | ||
"version": "5.6.0", | ||
"engines": { | ||
@@ -53,6 +53,6 @@ "node": ">=0.4.0" | ||
"rollup-plugin-buble": "^0.16.0", | ||
"test262": "git+https://github.com/tc39/test262.git#18c1e799a01cc976695983b61e225ce7959bdd91", | ||
"test262-parser-runner": "^0.3.1", | ||
"test262": "git+https://github.com/tc39/test262.git#3bfad28cc302fd4455badcfcbca7c5bb7ce41a72", | ||
"test262-parser-runner": "^0.4.0", | ||
"unicode-10.0.0": "^0.7.5" | ||
} | ||
} |
@@ -19,3 +19,3 @@ # Acorn | ||
and discussion, please use the | ||
[Tern discussion forum](https://discuss.acornjs.net). | ||
[Tern discussion forum](https://discuss.ternjs.net). | ||
@@ -70,3 +70,3 @@ ## Installation | ||
- **ecmaVersion**: Indicates the ECMAScript version to parse. Must be | ||
either 3, 5, 6 (2015), 7 (2016), 8 (2017), or 9 (2018, partial | ||
either 3, 5, 6 (2015), 7 (2016), 8 (2017), 9 (2018) or 10 (2019, partial | ||
support). This influences support for strict mode, the set of | ||
@@ -104,2 +104,4 @@ reserved words, and support for new syntax features. Default is 7. | ||
option to `true` allows them anywhere where a statement is allowed. | ||
- **allowAwaitOutsideFunction**: By default, `await` expressions can only appear inside `async` functions. Setting this option to `true` allows to have top-level `await` expressions. They are still not allowed in non-`async` functions, though. | ||
@@ -360,3 +362,3 @@ - **allowHashBang**: When this is enabled (off by default), if the | ||
- `--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9`: Sets the ECMAScript version | ||
- `--ecma3|--ecma5|--ecma6|--ecma7|--ecma8|--ecma9|--ecma10`: Sets the ECMAScript version | ||
to parse. Default is version 7. | ||
@@ -363,0 +365,0 @@ |
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
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
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
562714
12922
468
16