| 2 | import { sortBy } from './sort-by.js'; |
| 3 | |
| 4 | export function getTable(results: Record<string, SimpleReport>) { |
| 5 | const table = Object.keys(results) |
| 6 | // Add the framework name to the object |
| 7 | .map((framework) => ({ |
| 8 | name: framework, |
| 9 | ...results[framework], |
| 10 | })) |
| 11 | // Only include successful results (failed results have undefined values) |
| 12 | .filter((item) => typeof item.jsKb === 'number') |
| 13 | // Rank by tti |
| 14 | .sort(sortBy('ttiNumber')) |
| 15 | // Pick the display values |
| 16 | .map((item) => ({ |
| 17 | name: item.name, |
| 18 | TTI: item.ttiDisplay, |
| 19 | FCP: item.fcpDisplay, |
| 20 | LCP: item.lcpDisplay, |
| 21 | TBT: item.tbtDisplay, |
| 22 | Score: item.score, |
| 23 | 'Eager JS KiB': item.jsKb, |
| 24 | 'Total KiB': item.totalKb, |
| 25 | // Getting really weird results for LCP, commenting out for now |
| 26 | // LCP: item.lcpDisplay, |
| 27 | })); |
| 28 | |
| 29 | return table; |
| 30 | } |