Sha256: 7d4292d3b498d77982806c864dda6f39f6b6f1cc758ba117b66cc0430d45986e

Contents?: true

Size: 1.2 KB

Versions: 164

Compression:

Stored size: 1.2 KB

Contents

"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = traverse;
var _index = require("../definitions/index.js");
function traverse(node, handlers, state) {
  if (typeof handlers === "function") {
    handlers = {
      enter: handlers
    };
  }
  const {
    enter,
    exit
  } = handlers;
  traverseSimpleImpl(node, enter, exit, state, []);
}
function traverseSimpleImpl(node, enter, exit, state, ancestors) {
  const keys = _index.VISITOR_KEYS[node.type];
  if (!keys) return;
  if (enter) enter(node, ancestors, state);
  for (const key of keys) {
    const subNode = node[key];
    if (Array.isArray(subNode)) {
      for (let i = 0; i < subNode.length; i++) {
        const child = subNode[i];
        if (!child) continue;
        ancestors.push({
          node,
          key,
          index: i
        });
        traverseSimpleImpl(child, enter, exit, state, ancestors);
        ancestors.pop();
      }
    } else if (subNode) {
      ancestors.push({
        node,
        key
      });
      traverseSimpleImpl(subNode, enter, exit, state, ancestors);
      ancestors.pop();
    }
  }
  if (exit) exit(node, ancestors, state);
}

//# sourceMappingURL=traverse.js.map

Version data entries

164 entries across 16 versions & 3 rubygems

Version Path
immosquare-cleaner-0.1.48 node_modules/@babel/helper-split-export-declaration/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.48 node_modules/@babel/helper-skip-transparent-expression-wrappers/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.48 node_modules/@babel/helper-simple-access/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.48 node_modules/@babel/helper-remap-async-to-generator/node_modules/@babel/traverse/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.48 node_modules/@babel/helper-optimise-call-expression/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.48 node_modules/@babel/helper-module-imports/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.48 node_modules/@babel/helper-member-expression-to-functions/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.48 node_modules/@babel/helper-hoist-variables/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.48 node_modules/@babel/helper-function-name/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.48 node_modules/@babel/helper-environment-visitor/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.48 node_modules/@babel/helper-builder-binary-assignment-operator-visitor/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.47 node_modules/@babel/plugin-transform-react-jsx/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.47 node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.47 node_modules/@babel/preset-modules/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.47 node_modules/@babel/plugin-transform-object-super/node_modules/@babel/helper-replace-supers/node_modules/@babel/traverse/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.47 node_modules/@babel/plugin-transform-object-super/node_modules/@babel/helper-replace-supers/node_modules/@babel/helper-member-expression-to-functions/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.47 node_modules/@babel/plugin-transform-modules-systemjs/node_modules/@babel/traverse/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.47 node_modules/@babel/plugin-transform-function-name/node_modules/@babel/traverse/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.47 node_modules/@babel/plugin-transform-computed-properties/node_modules/@babel/template/node_modules/@babel/types/lib/traverse/traverse.js
immosquare-cleaner-0.1.47 node_modules/@babel/plugin-transform-classes/node_modules/@babel/traverse/node_modules/@babel/types/lib/traverse/traverse.js