median [min–max] over runs; the range is the point — never quote one run.
(runs, pick, fmt = (x) => String(Math.round(x)))
| 93 | |
| 94 | /** median [min–max] over runs; the range is the point — never quote one run. */ |
| 95 | function span(runs, pick, fmt = (x) => String(Math.round(x))) { |
| 96 | const xs = runs.map(pick).filter((x) => x !== null && x !== undefined && Number.isFinite(x)); |
| 97 | if (!xs.length) return '—'; |
| 98 | const m = fmt(median(xs)); |
| 99 | if (xs.length === 1) return m; |
| 100 | const lo = fmt(Math.min(...xs)); const hi = fmt(Math.max(...xs)); |
| 101 | return lo === hi ? m : `${m} [${lo}–${hi}]`; |
| 102 | } |
| 103 | |
| 104 | const int = (x) => Math.round(x).toLocaleString('en-US'); |
| 105 | const pct1 = (x) => `${x.toFixed(1)}%`; |
no test coverage detected