(element: IElement, fn: (element: IElement) => boolean)
| 388 | } |
| 389 | |
| 390 | export function findElement(element: IElement, fn: (element: IElement) => boolean): IElement | null { |
| 391 | const queue = [element]; |
| 392 | |
| 393 | while (queue.length > 0) { |
| 394 | const element = queue.shift()!; |
| 395 | |
| 396 | if (fn(element)) { |
| 397 | return element; |
| 398 | } |
| 399 | |
| 400 | queue.push(...element.children); |
| 401 | } |
| 402 | |
| 403 | return null; |
| 404 | } |
| 405 | |
| 406 | export function findElements(element: IElement, fn: (element: IElement) => boolean): IElement[] { |
| 407 | const result: IElement[] = []; |
no test coverage detected
searching dependent graphs…