source: imaps-frontend/node_modules/@babel/traverse/lib/index.js

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 2.6 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6Object.defineProperty(exports, "Hub", {
7 enumerable: true,
8 get: function () {
9 return _hub.default;
10 }
11});
12Object.defineProperty(exports, "NodePath", {
13 enumerable: true,
14 get: function () {
15 return _index.default;
16 }
17});
18Object.defineProperty(exports, "Scope", {
19 enumerable: true,
20 get: function () {
21 return _index2.default;
22 }
23});
24exports.visitors = exports.default = void 0;
25require("./path/context.js");
26var visitors = require("./visitors.js");
27exports.visitors = visitors;
28var _t = require("@babel/types");
29var cache = require("./cache.js");
30var _traverseNode = require("./traverse-node.js");
31var _index = require("./path/index.js");
32var _index2 = require("./scope/index.js");
33var _hub = require("./hub.js");
34const {
35 VISITOR_KEYS,
36 removeProperties,
37 traverseFast
38} = _t;
39function traverse(parent, opts = {}, scope, state, parentPath, visitSelf) {
40 if (!parent) return;
41 if (!opts.noScope && !scope) {
42 if (parent.type !== "Program" && parent.type !== "File") {
43 throw new Error("You must pass a scope and parentPath unless traversing a Program/File. " + `Instead of that you tried to traverse a ${parent.type} node without ` + "passing scope and parentPath.");
44 }
45 }
46 if (!parentPath && visitSelf) {
47 throw new Error("visitSelf can only be used when providing a NodePath.");
48 }
49 if (!VISITOR_KEYS[parent.type]) {
50 return;
51 }
52 visitors.explode(opts);
53 (0, _traverseNode.traverseNode)(parent, opts, scope, state, parentPath, null, visitSelf);
54}
55var _default = exports.default = traverse;
56traverse.visitors = visitors;
57traverse.verify = visitors.verify;
58traverse.explode = visitors.explode;
59traverse.cheap = function (node, enter) {
60 traverseFast(node, enter);
61 return;
62};
63traverse.node = function (node, opts, scope, state, path, skipKeys) {
64 (0, _traverseNode.traverseNode)(node, opts, scope, state, path, skipKeys);
65};
66traverse.clearNode = function (node, opts) {
67 removeProperties(node, opts);
68};
69traverse.removeProperties = function (tree, opts) {
70 traverseFast(tree, traverse.clearNode, opts);
71 return tree;
72};
73function hasDenylistedType(path, state) {
74 if (path.node.type === state.type) {
75 state.has = true;
76 path.stop();
77 }
78}
79traverse.hasType = function (tree, type, denylistTypes) {
80 if (denylistTypes != null && denylistTypes.includes(tree.type)) return false;
81 if (tree.type === type) return true;
82 const state = {
83 has: false,
84 type: type
85 };
86 traverse(tree, {
87 noScope: true,
88 denylist: denylistTypes,
89 enter: hasDenylistedType
90 }, null, state);
91 return state.has;
92};
93traverse.cache = cache;
94
95//# sourceMappingURL=index.js.map
Note: See TracBrowser for help on using the repository browser.