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

Method traverse

packages/graph/src/Steps.ts:4424–4457  ·  view source on GitHub ↗
(
    source: GraphSource<any>,
    input: Iterable<TraversalPath<any, any, any>>,
    _context?: QueryContext,
  )

Source from the content-addressed store, hash-verified

4422 }
4423
4424 public *traverse(
4425 source: GraphSource<any>,
4426 input: Iterable<TraversalPath<any, any, any>>,
4427 _context?: QueryContext,
4428 ): IterableIterator<TraversalPath<any, any, any>> {
4429 const { variables } = this.config;
4430
4431 for (const inputPath of input) {
4432 this.traversed++;
4433
4434 // Run the nested match steps against this single input path
4435 const matchResults = [...this.matchTraverser.traverse(source, [inputPath])] as TraversalPath<
4436 any,
4437 any,
4438 any
4439 >[];
4440
4441 if (matchResults.length > 0) {
4442 // Match found - yield all match results
4443 for (const result of matchResults) {
4444 this.emitted++;
4445 yield result;
4446 }
4447 } else {
4448 // No match - yield input path extended with null bindings
4449 let resultPath: TraversalPath<any, any, any> = inputPath;
4450 for (const variable of variables) {
4451 resultPath = resultPath.with(null, [variable]);
4452 }
4453 this.emitted++;
4454 yield resultPath;
4455 }
4456 }
4457 }
4458
4459 public override clone(partial?: Partial<OptionalMatchStepConfig>) {
4460 const { config, steps } = this;

Callers

nothing calls this directly

Calls 2

withMethod · 0.80
traverseMethod · 0.45

Tested by

no test coverage detected