| 2641 | } |
| 2642 | |
| 2643 | public *traverse( |
| 2644 | _source: GraphSource<any>, |
| 2645 | input: Iterable<unknown>, |
| 2646 | _context?: QueryContext, |
| 2647 | ): IterableIterator<number> { |
| 2648 | const { property } = this.config; |
| 2649 | let sum = 0; |
| 2650 | for (const path of input) { |
| 2651 | this.traversed++; |
| 2652 | if (path instanceof TraversalPath) { |
| 2653 | // If property is specified, get the property value; otherwise use the path value directly |
| 2654 | const value = property ? path.property(property as never) : path.value; |
| 2655 | if (typeof value === "number") { |
| 2656 | sum += value; |
| 2657 | } |
| 2658 | } |
| 2659 | } |
| 2660 | this.emitted++; |
| 2661 | yield sum; |
| 2662 | } |
| 2663 | |
| 2664 | public override clone(partial?: Partial<AggregateStepConfig>) { |
| 2665 | const { config } = this; |