| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent cc693eb commit 454b4f8
6 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,3 +1,11 @@ | |||
| 1 | + ## 8.3.1 (2023-12-06) | ||
| 2 | + | ||
| 3 | + ### Bug fixes | ||
| 4 | + | ||
| 5 | + Add `Function` and `Class` to the `AggregateType` type, so that they can be used in walkers without raising a type error. | ||
| 6 | + | ||
| 7 | + Visitor functions are now called in such a way that their `this` refers to the object they are part of. | ||
| 8 | + | ||
| 1 | 9 | ## 8.3.0 (2023-10-26) | |
| 2 | 10 | ||
| 3 | 11 | ### New features | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,8 @@ export type FullAncestorWalkerCallback<TState> = ( | |||
| 16 | 16 | type AggregateType = { | |
| 17 | 17 | Expression: acorn.Expression, | |
| 18 | 18 | Statement: acorn.Statement, | |
| 19 | + Function: acorn.Function, | ||
| 20 | + Class: acorn.Class, | ||
| 19 | 21 | Pattern: acorn.Pattern, | |
| 20 | 22 | ForInit: acorn.VariableDeclaration | acorn.Expression | |
| 21 | 23 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,6 +16,8 @@ export type FullAncestorWalkerCallback<TState> = ( | |||
| 16 | 16 | type AggregateType = { | |
| 17 | 17 | Expression: acorn.Expression, | |
| 18 | 18 | Statement: acorn.Statement, | |
| 19 | + Function: acorn.Function, | ||
| 20 | + Class: acorn.Class, | ||
| 19 | 21 | Pattern: acorn.Pattern, | |
| 20 | 22 | ForInit: acorn.VariableDeclaration | acorn.Expression | |
| 21 | 23 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,7 +4,7 @@ | |||
| 4 | 4 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.acorn = global.acorn || {}, global.acorn.walk = {}))); | |
| 5 | 5 | })(this, (function (exports) { 'use strict'; | |
| 6 | 6 | ||
| 7 | - // AST walker module for Mozilla Parser API compatible trees | ||
| 7 | + // AST walker module for ESTree compatible trees | ||
| 8 | 8 | ||
| 9 | 9 | // A simple walk is one where you simply specify callbacks to be | |
| 10 | 10 | // called on specific nodes. The last two arguments are optional. A | |
@@ -14,7 +14,7 @@ | |||
| 14 | 14 | // Expression: function(node) { ... } | |
| 15 | 15 | // }); | |
| 16 | 16 | // | |
| 17 | - // to do something with all expressions. All Parser API node types | ||
| 17 | + // to do something with all expressions. All ESTree node types | ||
| 18 | 18 | // can be used to identify node types, as well as Expression and | |
| 19 | 19 | // Statement, which denote categories of nodes. | |
| 20 | 20 | // | |
@@ -25,9 +25,9 @@ | |||
| 25 | 25 | function simple(node, visitors, baseVisitor, state, override) { | |
| 26 | 26 | if (!baseVisitor) { baseVisitor = base | |
| 27 | 27 | ; }(function c(node, st, override) { | |
| 28 | - var type = override || node.type, found = visitors[type]; | ||
| 28 | + var type = override || node.type; | ||
| 29 | 29 | baseVisitor[type](node, st, c); | |
| 30 | - if (found) { found(node, st); } | ||
| 30 | + if (visitors[type]) { visitors[type](node, st); } | ||
| 31 | 31 | })(node, state, override); | |
| 32 | 32 | } | |
| 33 | 33 | ||
@@ -38,11 +38,11 @@ | |||
| 38 | 38 | var ancestors = []; | |
| 39 | 39 | if (!baseVisitor) { baseVisitor = base | |
| 40 | 40 | ; }(function c(node, st, override) { | |
| 41 | - var type = override || node.type, found = visitors[type]; | ||
| 41 | + var type = override || node.type; | ||
| 42 | 42 | var isNew = node !== ancestors[ancestors.length - 1]; | |
| 43 | 43 | if (isNew) { ancestors.push(node); } | |
| 44 | 44 | baseVisitor[type](node, st, c); | |
| 45 | - if (found) { found(node, st || ancestors, ancestors); } | ||
| 45 | + if (visitors[type]) { visitors[type](node, st || ancestors, ancestors); } | ||
| 46 | 46 | if (isNew) { ancestors.pop(); } | |
| 47 | 47 | })(node, state, override); | |
| 48 | 48 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,4 +1,4 @@ | |||
| 1 | - // AST walker module for Mozilla Parser API compatible trees | ||
| 1 | + // AST walker module for ESTree compatible trees | ||
| 2 | 2 | ||
| 3 | 3 | // A simple walk is one where you simply specify callbacks to be | |
| 4 | 4 | // called on specific nodes. The last two arguments are optional. A | |
@@ -8,7 +8,7 @@ | |||
| 8 | 8 | // Expression: function(node) { ... } | |
| 9 | 9 | // }); | |
| 10 | 10 | // | |
| 11 | - // to do something with all expressions. All Parser API node types | ||
| 11 | + // to do something with all expressions. All ESTree node types | ||
| 12 | 12 | // can be used to identify node types, as well as Expression and | |
| 13 | 13 | // Statement, which denote categories of nodes. | |
| 14 | 14 | // | |
@@ -19,9 +19,9 @@ | |||
| 19 | 19 | function simple(node, visitors, baseVisitor, state, override) { | |
| 20 | 20 | if (!baseVisitor) { baseVisitor = base | |
| 21 | 21 | ; }(function c(node, st, override) { | |
| 22 | - var type = override || node.type, found = visitors[type]; | ||
| 22 | + var type = override || node.type; | ||
| 23 | 23 | baseVisitor[type](node, st, c); | |
| 24 | - if (found) { found(node, st); } | ||
| 24 | + if (visitors[type]) { visitors[type](node, st); } | ||
| 25 | 25 | })(node, state, override); | |
| 26 | 26 | } | |
| 27 | 27 | ||
@@ -32,11 +32,11 @@ function ancestor(node, visitors, baseVisitor, state, override) { | |||
| 32 | 32 | var ancestors = []; | |
| 33 | 33 | if (!baseVisitor) { baseVisitor = base | |
| 34 | 34 | ; }(function c(node, st, override) { | |
| 35 | - var type = override || node.type, found = visitors[type]; | ||
| 35 | + var type = override || node.type; | ||
| 36 | 36 | var isNew = node !== ancestors[ancestors.length - 1]; | |
| 37 | 37 | if (isNew) { ancestors.push(node); } | |
| 38 | 38 | baseVisitor[type](node, st, c); | |
| 39 | - if (found) { found(node, st || ancestors, ancestors); } | ||
| 39 | + if (visitors[type]) { visitors[type](node, st || ancestors, ancestors); } | ||
| 40 | 40 | if (isNew) { ancestors.pop(); } | |
| 41 | 41 | })(node, state, override); | |
| 42 | 42 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,7 @@ | |||
| 16 | 16 | ], | |
| 17 | 17 | "./package.json": "./package.json" | |
| 18 | 18 | }, | |
| 19 | - "version": "8.3.0", | ||
| 19 | + "version": "8.3.1", | ||
| 20 | 20 | "engines": { | |
| 21 | 21 | "node": ">=0.4.0" | |
| 22 | 22 | }, | |
| Back | FazBrowse Home | New Git URL |
0 commit comments