MCPcopy Create free account
hub / github.com/andywer/postguard / traverseSubTree

Function traverseSubTree

src/postgres/query-traversal.ts:59–73  ·  view source on GitHub ↗
(path: QueryNodePath<QueryNode<any>>, callback: TraversalCallback)

Source from the content-addressed store, hash-verified

57}
58
59export function traverseSubTree(path: QueryNodePath<QueryNode<any>>, callback: TraversalCallback) {
60 const callbackResult = callback(path, $cancelToken)
61 if (callbackResult === $cancelToken) return
62
63 for (const key of Object.keys((path.node as any)[path.type])) {
64 const propValue = (path.node as any)[path.type][key]
65
66 if (Array.isArray(propValue)) {
67 traverseArray(path, propValue, key, callback)
68 } else if (propValue && typeof propValue === "object") {
69 const propPath = createQueryNodeSubpath(path, propValue, key)
70 traverseSubTree(propPath, callback)
71 }
72 }
73}
74
75export function getQueryPathParent(
76 path: QueryNodePath<QueryNode<any>>

Callers 4

getSubqueriesFunction · 0.90
getTableReferencesFunction · 0.90
getReferencedColumnsFunction · 0.90
traverseArrayFunction · 0.85

Calls 2

traverseArrayFunction · 0.85
createQueryNodeSubpathFunction · 0.85

Tested by

no test coverage detected