( rows: Row[], )
| 37 | } |
| 38 | |
| 39 | export function splitRowsByRoot<Row extends { depth: number }>( |
| 40 | rows: Row[], |
| 41 | ): RootRowGroup<Row>[] { |
| 42 | const groups: RootRowGroup<Row>[] = []; |
| 43 | let current: Row[] = []; |
| 44 | let currentRootIndex = 0; |
| 45 | |
| 46 | rows.forEach((row, rowIndex) => { |
| 47 | if (row.depth === 0 && current.length > 0) { |
| 48 | groups.push({ |
| 49 | root: current[0], |
| 50 | rootIndex: currentRootIndex, |
| 51 | rows: current, |
| 52 | }); |
| 53 | current = [row]; |
| 54 | currentRootIndex = rowIndex; |
| 55 | return; |
| 56 | } |
| 57 | if (current.length === 0) { |
| 58 | currentRootIndex = rowIndex; |
| 59 | } |
| 60 | current.push(row); |
| 61 | }); |
| 62 | |
| 63 | if (current.length > 0) { |
| 64 | groups.push({ |
| 65 | root: current[0], |
| 66 | rootIndex: currentRootIndex, |
| 67 | rows: current, |
| 68 | }); |
| 69 | } |
| 70 | |
| 71 | return groups; |
| 72 | } |
| 73 | |
| 74 | export function filterRowsByQuery<Row extends { depth: number; thread: ThreadSummary }>( |
| 75 | rows: Row[], |
no outgoing calls
no test coverage detected