MCPcopy Create free account
hub / github.com/codemix/graph / get

Method get

packages/graph/src/Traversals.ts:216–227  ·  view source on GitHub ↗

* Get a node in the path by label. * @param label The label to get the node by.

(
    label: TLabel,
  )

Source from the content-addressed store, hash-verified

214 * @param label The label to get the node by.
215 */
216 public get<const TLabel extends string>(
217 label: TLabel,
218 ): GetTraversalPathByLabel<TraversalPath<TParent, TValue, TLabels>, TLabel> {
219 let node: TraversalPath<any, any, any> = this;
220 while (node !== undefined) {
221 if (node.labels.includes(label)) {
222 return node as GetTraversalPathByLabel<TraversalPath<TParent, TValue, TLabels>, TLabel>;
223 }
224 node = node.parent;
225 }
226 return undefined as GetTraversalPathByLabel<TraversalPath<TParent, TValue, TLabels>, TLabel>;
227 }
228
229 /**
230 * Get all the node in the path by label.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected