Function
findElements
(element: IElement, fn: (element: IElement) => boolean)
Source from the content-addressed store, hash-verified
| 404 | } |
| 405 | |
| 406 | export function findElements(element: IElement, fn: (element: IElement) => boolean): IElement[] { |
| 407 | const result: IElement[] = []; |
| 408 | const queue = [element]; |
| 409 | |
| 410 | while (queue.length > 0) { |
| 411 | const element = queue.shift()!; |
| 412 | |
| 413 | if (fn(element)) { |
| 414 | result.push(element); |
| 415 | } |
| 416 | |
| 417 | queue.push(...element.children); |
| 418 | } |
| 419 | |
| 420 | return result; |
| 421 | } |
Tested by
no test coverage detected
Used in the wild real call sites across dependent graphs
searching dependent graphs…