traverse-node.js 580 B

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.traverseNode = traverseNode;
  6. var _context = require("./context");
  7. var _t = require("@babel/types");
  8. const {
  9. VISITOR_KEYS
  10. } = _t;
  11. function traverseNode(node, opts, scope, state, path, skipKeys) {
  12. const keys = VISITOR_KEYS[node.type];
  13. if (!keys) return false;
  14. const context = new _context.default(scope, opts, state, path);
  15. for (const key of keys) {
  16. if (skipKeys && skipKeys[key]) continue;
  17. if (context.visit(node, key)) {
  18. return true;
  19. }
  20. }
  21. return false;
  22. }