MCPcopy Create free account
hub / github.com/neomjs/neo / postOrderWalk

Function postOrderWalk

buildScripts/util/astTemplateProcessor.mjs:101–114  ·  view source on GitHub ↗

* Performs a true post-order traversal of the AST (children before parent). * This traversal strategy is essential for this transformation. By processing the innermost * `html` templates first, we ensure that a nested template is already converted into an * `ObjectExpression` before its parent te

(node, visitor)

Source from the content-addressed store, hash-verified

99 * @private
100 */
101function postOrderWalk(node, visitor) {
102 if (!node) return;
103
104 Object.entries(node).forEach(([key, value]) => {
105 if (key === 'parent') return;
106 if (Array.isArray(value)) {
107 value.forEach(child => postOrderWalk(child, visitor));
108 } else if (typeof value === 'object' && value !== null) {
109 postOrderWalk(value, visitor);
110 }
111 });
112
113 visitor(node);
114}
115
116/**
117 * Recursively adds parent pointers to each node in the AST.

Callers 1

processFileContentFunction · 0.85

Calls 2

isArrayMethod · 0.80
forEachMethod · 0.45

Tested by

no test coverage detected