|
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 | 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 | 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 | 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 | }
|
|
0 commit comments