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

Method traverse

packages/graph/src/Steps.ts:2679–2700  ·  view source on GitHub ↗
(
    _source: GraphSource<any>,
    input: Iterable<unknown>,
    _context?: QueryContext,
  )

Source from the content-addressed store, hash-verified

2677 }
2678
2679 public *traverse(
2680 _source: GraphSource<any>,
2681 input: Iterable<unknown>,
2682 _context?: QueryContext,
2683 ): IterableIterator<number | null> {
2684 const { property } = this.config;
2685 let sum = 0;
2686 let count = 0;
2687 for (const path of input) {
2688 this.traversed++;
2689 if (path instanceof TraversalPath) {
2690 // If property is specified, get the property value; otherwise use the path value directly
2691 const value = property ? path.property(property as never) : path.value;
2692 if (typeof value === "number") {
2693 sum += value;
2694 count++;
2695 }
2696 }
2697 }
2698 this.emitted++;
2699 yield count > 0 ? sum / count : null;
2700 }
2701
2702 public override clone(partial?: Partial<AggregateStepConfig>) {
2703 const { config } = this;

Callers

nothing calls this directly

Calls 1

propertyMethod · 0.45

Tested by

no test coverage detected