persona-community-5/.pnpm-store/v3/files/c4/6095d22e9abfa90d03bd34c6f93cb86d96b0f97b2deb9017a55ad44ddb9ae3bc5bd50b509c779ce239fb5e61f7efe929b4044cfad8b1e833a8aa0175b8aa4d
rdev-worker a1d0d1bf1c
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
build: /implement-feature community-ui --requirements 'Build the React commu...
2026-02-24 08:22:30 +00:00

57 lines
1.9 KiB
Plaintext

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.simpleTraverse = simpleTraverse;
const visitor_keys_1 = require("@typescript-eslint/visitor-keys");
function isValidNode(x) {
return (typeof x === 'object' &&
x != null &&
'type' in x &&
typeof x.type === 'string');
}
function getVisitorKeysForNode(allVisitorKeys, node) {
const keys = allVisitorKeys[node.type];
return (keys ?? []);
}
class SimpleTraverser {
constructor(selectors, setParentPointers = false) {
this.allVisitorKeys = visitor_keys_1.visitorKeys;
this.selectors = selectors;
this.setParentPointers = setParentPointers;
if (selectors.visitorKeys) {
this.allVisitorKeys = selectors.visitorKeys;
}
}
traverse(node, parent) {
if (!isValidNode(node)) {
return;
}
if (this.setParentPointers) {
node.parent = parent;
}
if ('enter' in this.selectors) {
this.selectors.enter(node, parent);
}
else if (node.type in this.selectors.visitors) {
this.selectors.visitors[node.type](node, parent);
}
const keys = getVisitorKeysForNode(this.allVisitorKeys, node);
if (keys.length < 1) {
return;
}
for (const key of keys) {
const childOrChildren = node[key];
if (Array.isArray(childOrChildren)) {
for (const child of childOrChildren) {
this.traverse(child, node);
}
}
else {
this.traverse(childOrChildren, node);
}
}
}
}
function simpleTraverse(startingNode, options, setParentPointers = false) {
new SimpleTraverser(options, setParentPointers).traverse(startingNode, undefined);
}
//# sourceMappingURL=simple-traverse.js.map