(
source: GraphSource<any>,
input: Iterable<TraversalPath<any, any, any>>,
context?: QueryContext,
)
| 5459 | } |
| 5460 | |
| 5461 | public *traverse( |
| 5462 | source: GraphSource<any>, |
| 5463 | input: Iterable<TraversalPath<any, any, any>>, |
| 5464 | context?: QueryContext, |
| 5465 | ): IterableIterator<TraversalPath<any, any, any>> { |
| 5466 | const { variable, listExpression } = this.config; |
| 5467 | |
| 5468 | for (const path of input) { |
| 5469 | this.traversed++; |
| 5470 | |
| 5471 | // Get the list to iterate over |
| 5472 | let listValue: readonly any[]; |
| 5473 | |
| 5474 | if (listExpression) { |
| 5475 | if (listExpression.type === "literal") { |
| 5476 | // Literal list - use the values directly |
| 5477 | listValue = listExpression.values; |
| 5478 | } else if (listExpression.type === "property") { |
| 5479 | // Property access - get the property from the variable bound in the path |
| 5480 | const variablePath = path.get(listExpression.variable); |
| 5481 | if (!variablePath) { |
| 5482 | // Variable not found - skip this path but still yield it |
| 5483 | this.emitted++; |
| 5484 | yield path; |
| 5485 | continue; |
| 5486 | } |
| 5487 | const element = variablePath.value; |
| 5488 | if (element instanceof Vertex || element instanceof Edge) { |
| 5489 | const propValue = element.get(listExpression.property as never); |
| 5490 | if (!Array.isArray(propValue)) { |
| 5491 | // Property is not an array - skip this path but still yield it |
| 5492 | this.emitted++; |
| 5493 | yield path; |
| 5494 | continue; |
| 5495 | } |
| 5496 | listValue = propValue; |
| 5497 | } else { |
| 5498 | // Not a graph element - skip this path but still yield it |
| 5499 | this.emitted++; |
| 5500 | yield path; |
| 5501 | continue; |
| 5502 | } |
| 5503 | } else if (listExpression.type === "variable") { |
| 5504 | // Variable reference - get the value directly from the path |
| 5505 | const variablePath = path.get(listExpression.variable); |
| 5506 | if (!variablePath) { |
| 5507 | // Variable not found - skip this path but still yield it |
| 5508 | this.emitted++; |
| 5509 | yield path; |
| 5510 | continue; |
| 5511 | } |
| 5512 | const value = variablePath.value; |
| 5513 | if (!Array.isArray(value)) { |
| 5514 | // Not an array - skip this path but still yield it |
| 5515 | this.emitted++; |
| 5516 | yield path; |
| 5517 | continue; |
| 5518 | } |
nothing calls this directly
no test coverage detected