Canonical format: "5 kg", "320 lux", "55.845 g/mol".
Instrument / analyze emission. Same wrapper, canonical text
inside. The optional scaleName flows through to the
<quantity tag="..."> attribute when a tag table is
registered for the unit at that scale.
Optional_viewer: unknownOptionalscaleName: stringTag-table lookup. Returns the registered tag string when one
is defined for the unit; otherwise falls back to the canonical
format (so Quantity<g/mol>.tag() reads "55.845 g/mol", not
"" or null).
The optional scaleName selects which vocabulary to consult
when the unit has multiple registered scales (e.g. 'color'
vs 'thermal' for K). Without scaleName, falls back to the
unit's default scale.
OptionalscaleName: stringCross-unit conversion. Returns a Quantity<Unit> rather than a
narrowly-typed Quantity<TargetUnit> because the target is a
runtime parameter — callers that need narrow typing should call
the unit-specific accessor on their host (e.g.
light.intensity is statically Quantity<'lux'>).
Default-prose emission. Inner text is the tag (or canonical
format for tagless units). Viewer parameter is forward-compat
for the deferred pedagogical-seam setting. Optional
scaleName picks the vocabulary when multiple scales are
registered for the unit; default scale otherwise.
Optional_viewer: unknownOptionalscaleName: stringStatic_Drop a registered scale for unit. When scaleName is
omitted, removes every scale registered for the unit. Used by
QuantityApi's reload path to handle entries that disappeared
from the YAML, and by tests to reset registry state.
OptionalscaleName: stringStatic_Inspect the registered default scale for a unit; null if unset.
Static_Snapshot of the (unit, scaleName) pairs currently carrying a
registered table. Used by QuantityApi.reloadTagTables to
compute which scales to delete after a re-read.
StaticcompareCompare two tags by their position in a (unit, scaleName)'s
registered ordering. Returns a sign-only integer (negative when
a precedes b, zero when equal, positive when a follows
b) — same shape as Array.prototype.sort's comparator.
Throws when no table is registered for the pair, or when either tag isn't present in the resolved table.
OptionalscaleName: stringStaticfromStaticfromTag-table reverse lookup. Resolves through the registered
table to a canonical numeric value. The optional scaleName
picks which vocabulary to consult when the unit has multiple
registered scales (e.g. 'color' vs 'thermal' for K).
Without scaleName, falls back to the unit's default scale.
Throws for tags absent from the resolved table, or for unit / scale pairs with no registered table.
OptionalscaleName: stringStaticofStaticparseAuthoring-friendly parse. Four input shapes:
"heavy" → registered threshold for the target unit."12 kg" → Quantity<kg>(12)."12000 g" (target kg) → Quantity<kg>(12).5 or "5" →
canonical-unit interpretation. mass: 5 on a Quantity<kg>
field is 5 kg, not 5 g.The optional scaleName selects which tag table to consult when
the input is a tag string and the target unit has multiple
scales registered.
Throws on unrecognized tag, unparseable literal, or alt-unit with no registered converter to the target.
OptionalscaleName: stringStaticregisterRegister a tag table for (unit, scaleName). Replaces any
prior table at that pair. First scale registered for a unit
becomes that unit's default scale (the one tag() /
parse() / fromTag() consult when no scale name is given);
setDefaultScale overrides explicitly.
scaleName defaults to DEFAULT_SCALE ('default') for
single-vocabulary units like kg or lux. Units with
multiple vocabularies (K's color vs thermal) register each
scale by an explicit name.
StaticsetPick which scale tag() / parse() / fromTag() consult for
unit when no scaleName is passed. Throws if the scale
isn't registered for that unit.
StaticshiftShift a tag by integer band offset within its registered
(unit, scaleName) ordering. Clamps to the [first, last] band
range; non-finite shifts are treated as zero (the input tag
passes through unchanged).
Throws when:
tag isn't present in the resolved table.Worked example: shiftTag('lux', 'lit', -2) → 'very-dim'
(assuming the lux scale order pitch-black/very-dim/dim/lit/
bright/blinding). shiftTag('lux', 'pitch-black', -10) →
'pitch-black' (clamped at the floor).
OptionalscaleName: stringStatictagsOrdered tag list for a (unit, scaleName) pair. Order is
ascending by threshold (the registry sorts entries on register
for tagFor's descending walk; this helper exposes the same
ordering as a plain string array for callers that need to do
shift/compare arithmetic over tag bands).
Returns an empty array when no table is registered for the
pair. scaleName defaults to the unit's registered default
scale.
Cross-unit consumer pattern: LightBand is the lux scale's
tag list; a future thermal-K scale would expose its own
ordered tag list the same way.
OptionalscaleName: string
Canonical-unit numeric value. Public-readonly so
JSON.stringifyproduces the persistence shape directly (matchesLight's pattern). UserawValue()from inter-Stuff call sites; the field is structural for serialization.