minor adjustment to readme
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / @typescript-eslint / parser / dist / simple-traverse.js
1 "use strict";
2 Object.defineProperty(exports, "__esModule", { value: true });
3 const visitor_keys_1 = require("./visitor-keys");
4 // eslint-disable-next-line @typescript-eslint/no-explicit-any
5 function isValidNode(x) {
6     return x !== null && typeof x === 'object' && typeof x.type === 'string';
7 }
8 function getVisitorKeysForNode(allVisitorKeys, node) {
9     const keys = allVisitorKeys[node.type];
10     return keys || [];
11 }
12 class SimpleTraverser {
13     constructor({ enter }) {
14         this.allVisitorKeys = visitor_keys_1.visitorKeys;
15         this.enter = enter;
16     }
17     traverse(node, parent) {
18         if (!isValidNode(node)) {
19             return;
20         }
21         this.enter(node, parent);
22         const keys = getVisitorKeysForNode(this.allVisitorKeys, node);
23         if (keys.length < 1) {
24             return;
25         }
26         for (const key of keys) {
27             const childOrChildren = node[key];
28             if (Array.isArray(childOrChildren)) {
29                 for (const child of childOrChildren) {
30                     this.traverse(child, node);
31                 }
32             }
33             else {
34                 this.traverse(childOrChildren, node);
35             }
36         }
37     }
38 }
39 function simpleTraverse(startingNode, options) {
40     new SimpleTraverser(options).traverse(startingNode, undefined);
41 }
42 exports.simpleTraverse = simpleTraverse;
43 //# sourceMappingURL=simple-traverse.js.map