* Coalesce entries by calendar day, keeping the last run of each day. * Entries must be sorted oldest-first.
(entries)
| 320 | * Entries must be sorted oldest-first. |
| 321 | */ |
| 322 | function coalesceByDay(entries) { |
| 323 | const byDay = new Map(); |
| 324 | for (const entry of entries) { |
| 325 | const day = entry.timestamp.slice(0, 10); // YYYY-MM-DD |
| 326 | byDay.set(day, entry); // later entries overwrite earlier ones |
| 327 | } |
| 328 | return Array.from(byDay.values()); |
| 329 | } |
| 330 | |
| 331 | /** |
| 332 | * Thin an array to at most maxPoints by picking evenly spaced entries. |
no test coverage detected