MCPcopy Index your code
hub / github.com/TanStack/devtools / forEachChild

Function forEachChild

packages/devtools-vite/src/ast-utils.ts:31–46  ·  view source on GitHub ↗
(node: Node, callback: (child: Node) => void)

Source from the content-addressed store, hash-verified

29 * allocating Object.entries() arrays on every call.
30 */
31export function forEachChild(node: Node, callback: (child: Node) => void) {
32 const keys = getChildKeys(node)
33 for (const key of keys) {
34 const value = (node as any)[key]
35 if (value === null) continue
36 if (Array.isArray(value)) {
37 for (const item of value) {
38 if (typeof item === 'object' && item !== null && 'type' in item) {
39 callback(item)
40 }
41 }
42 } else if ('type' in value) {
43 callback(value as Node)
44 }
45 }
46}
47
48/**
49 * Recursively walk AST nodes, calling `visitor` for each node with a `type`.

Callers 4

collectJsxFunction · 0.90
visitFunctionsFunction · 0.90
ast-utils.test.tsFile · 0.90
walkFunction · 0.85

Calls 1

getChildKeysFunction · 0.85

Tested by

no test coverage detected