* Thin an array to at most maxPoints by picking evenly spaced entries. * Always includes first and last.
(entries, maxPoints)
| 333 | * Always includes first and last. |
| 334 | */ |
| 335 | function thinEvenly(entries, maxPoints) { |
| 336 | if (entries.length <= maxPoints) return entries; |
| 337 | const result = []; |
| 338 | const step = (entries.length - 1) / (maxPoints - 1); |
| 339 | for (let i = 0; i < maxPoints; i++) { |
| 340 | result.push(entries[Math.round(i * step)]); |
| 341 | } |
| 342 | return result; |
| 343 | } |
| 344 | |
| 345 | /** |
| 346 | * Given a full list of entries (oldest-first), return a sampled subset |
no test coverage detected