InternalCoercion hook: returns the unit-bearing string for "string" hints (String(x), template
literals), throws otherwise. Prevents +, -, *, ==, Number(x), etc. from silently
stripping the unit — use AmountWithUnit.toAmount for explicit numeric access.
Optionaldenominator: numberOptionaldenominator: numberUnit-bearing canonical form, e.g. "[sat]: 100". Used by String(x), template literals,
console.log, and any other string-coercion context.
Leads with [ (never a digit, sign, or decimal point) so that parseInt(String(x)) /
parseFloat(String(x)) return NaN even if the unit itself starts with digits — otherwise a
unit like "9999sat" would let parseInt silently extract 9999 from the unit and drop the
real amount.
StaticfromStaticmaxStaticminStaticoneStaticsumSum a unit-tagged iterable.
unit is provided, every element must match it; the result has that unit. An empty iterable
returns AmountWithUnit.zero(unit).unit is omitted, the iterable must be non-empty; the unit is inferred from the first
element and every subsequent element must match. An empty iterable throws.Optionalunit: stringStaticzero
Immutable Amount paired with a currency unit.
Binary ops require matching units (throw AmountWithUnitError otherwise); scalar ops preserve the unit.
Lift via Amount.withUnit / AmountWithUnit.from, drop via AmountWithUnit.toAmount.
Example