MCPcopy
hub / github.com/mourner/suncalc / table

Function table

test/validate.js:12–21  ·  view source on GitHub ↗
(title, fields, unit, scale = 1)

Source from the content-addressed store, hash-verified

10
11const fmt = (v, u) => v >= 100 ? v.toFixed(0) + u : v >= 1 ? v.toFixed(2) + u : v.toFixed(3) + u;
12function table(title, fields, unit, scale = 1) {
13 console.log(`\n${title}`);
14 console.log(' field'.padEnd(22) + ['n', 'mean', 'p50', 'p90', 'max'].map(h => h.padStart(9)).join(''));
15 for (const f of fields) {
16 const s = stats(collectors[f]);
17 if (!s) continue;
18 console.log(` ${ f.padEnd(20) }${String(s.n).padStart(9)
19 }${[s.mean, s.p50, s.p90, s.max].map(v => fmt(v * scale, unit).padStart(9)).join('')}`);
20 }
21}
22
23console.log(`SunCalc validation vs external truth (fixtures generated ${fx.generated})`);
24table('Sun position (deg vs JPL Horizons, refracted)', ['sun.altitude', 'sun.azimuth', 'sun.angularSep'], '°');

Callers 1

validate.jsFile · 0.85

Calls 2

statsFunction · 0.90
fmtFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…