MCPcopy Create free account
hub / github.com/csskit/csskit / thinEvenly

Function thinEvenly

website/script/benchmarks.js:335–343  ·  view source on GitHub ↗

* Thin an array to at most maxPoints by picking evenly spaced entries. * Always includes first and last.

(entries, maxPoints)

Source from the content-addressed store, hash-verified

333 * Always includes first and last.
334 */
335function 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

Callers 2

sampleEntriesFunction · 0.85
sampleEntriesWindowFunction · 0.85

Calls 1

roundMethod · 0.80

Tested by

no test coverage detected