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

Function traverseArray

src/postgres/query-traversal.ts:41–57  ·  view source on GitHub ↗
(
  path: QueryNodePath<QueryNode<any>>,
  array: any[],
  parentPropKey: string,
  callback: TraversalCallback
)

Source from the content-addressed store, hash-verified

39type TraversalCallback = (path: QueryNodePath<any>, cancelRecursionToken: symbol) => symbol | void
40
41function traverseArray(
42 path: QueryNodePath<QueryNode<any>>,
43 array: any[],
44 parentPropKey: string,
45 callback: TraversalCallback
46) {
47 for (const item of array) {
48 if (!item) continue
49
50 if (Array.isArray(item)) {
51 traverseArray(path, item, parentPropKey, callback)
52 } else {
53 const itemPath = createQueryNodeSubpath(path, item, parentPropKey)
54 traverseSubTree(itemPath, callback)
55 }
56 }
57}
58
59export function traverseSubTree(path: QueryNodePath<QueryNode<any>>, callback: TraversalCallback) {
60 const callbackResult = callback(path, $cancelToken)

Callers 1

traverseSubTreeFunction · 0.85

Calls 2

createQueryNodeSubpathFunction · 0.85
traverseSubTreeFunction · 0.85

Tested by

no test coverage detected