(sections: TwinSection[], limit: number)
| 801 | * would be rebuilding a thing that already worked. |
| 802 | */ |
| 803 | export function topFacts(sections: TwinSection[], limit: number): TwinFactRow[] { |
| 804 | const queues = sections.filter(section => section.rows.length > 0); |
| 805 | const facts: TwinFactRow[] = []; |
| 806 | for (let round = 0; facts.length < limit; round++) { |
| 807 | let took = false; |
| 808 | for (const section of queues) { |
| 809 | const row = section.rows[round]; |
| 810 | if (row === undefined) { |
| 811 | continue; |
| 812 | } |
| 813 | took = true; |
| 814 | facts.push({ |
| 815 | id: `${section.name}-${row.id}`, |
| 816 | label: section.title, |
| 817 | name: row.label, |
| 818 | target: row.target, |
| 819 | factPath: row.factPath |
| 820 | }); |
| 821 | if (facts.length === limit) { |
| 822 | return facts; |
| 823 | } |
| 824 | } |
| 825 | if (!took) { |
| 826 | return facts; |
| 827 | } |
| 828 | } |
| 829 | return facts; |
| 830 | } |
| 831 | |
| 832 | /** |
| 833 | * The sentences a family's emptiness deserves. |
no test coverage detected