( node: ContainerNode, query: NodeQuery )
| 526 | * ``` |
| 527 | */ |
| 528 | export function findOne<T extends DesignNode = DesignNode>( |
| 529 | node: ContainerNode, |
| 530 | query: NodeQuery |
| 531 | ): T | null { |
| 532 | for (const child of node.children) { |
| 533 | if (matchNode(child, query)) { |
| 534 | return child as T |
| 535 | } |
| 536 | if ('children' in child) { |
| 537 | const result = findOne(child, query) |
| 538 | if (result) { |
| 539 | return result as T |
| 540 | } |
| 541 | } |
| 542 | } |
| 543 | return null |
| 544 | } |
| 545 | |
| 546 | /** |
| 547 | * Depth-first search returning every node that matches the query. |
no test coverage detected