size-baseline-extract.ts
@file The extraction logic, separate from the file I/O in…
Overview
@file The extraction logic, separate from the file I/O in build-size-baseline.ts so size-baseline.test.ts can drive it against a fresh read without importing a script that writes files as a side effect.
depends on size-baseline.ts · used by build-size-baseline.ts
flowchart TD extractPrimary --> pick
API
Fexport function extractPrimary(raw: unknown): SizeBaseline | null
Same shape check src/size-baseline.ts does at runtime, reused so the
generator and the (unused, but retained as a fallback contract) runtime
reader agree on what "parseable" means.
pickFconst pick = (r: { size: number; used: number; free: number; pct: number }) => ({ size: r.size, used: r.used, free: r.free, pct: r.pct, })
Picked field by field rather than spread: the source objects carry origin/used_by_sections/load_images/padding too, which nothing here reads, and copying them would both widen RegionUsage for no reason and silently re-fatten the generated file the next time the source schema grows a field.
extractPrimary