| 2808 | } |
| 2809 | |
| 2810 | public *traverse( |
| 2811 | _source: GraphSource<any>, |
| 2812 | input: Iterable<unknown>, |
| 2813 | _context?: QueryContext, |
| 2814 | ): IterableIterator<unknown[]> { |
| 2815 | const maxCollectionSize = _context?.options.maxCollectionSize ?? DEFAULT_MAX_COLLECTION_SIZE; |
| 2816 | const collected: unknown[] = []; |
| 2817 | for (const path of input) { |
| 2818 | this.traversed++; |
| 2819 | if (collected.length >= maxCollectionSize) { |
| 2820 | throw new MemoryLimitExceededError(maxCollectionSize, collected.length); |
| 2821 | } |
| 2822 | if (path instanceof TraversalPath) { |
| 2823 | collected.push(path.value); |
| 2824 | } else { |
| 2825 | collected.push(path); |
| 2826 | } |
| 2827 | } |
| 2828 | this.emitted++; |
| 2829 | yield collected; |
| 2830 | } |
| 2831 | |
| 2832 | public override clone(partial?: Partial<CollectStepConfig>) { |
| 2833 | const { config } = this; |