convertTo Method
Convert a Quantity to the specified unit given the UnitConversion.
convertTo(toUnit: UnitProps, conversion: UnitConversionProps): Quantity
@throws QuantityError with InvalidUnitConversion when conversion.error === true.
@throws QuantityError with InvertingZero when inversion would require dividing by zero or almost-zero.
| Parameter | Type | Description |
|---|---|---|
| toUnit | UnitProps | The new unit for the quantity. |
| conversion | UnitConversionProps | Defines the information needed to convert the Quantity's magnitude from the current unit to another unit. This conversion info is usually returned from the UnitsProvider. |
Returns - Quantity
Defined in
- quantity/src/Quantity.ts Line 61
Last Updated: 08 July, 2026
Found something wrong, missing, or unclear on this page? Raise an issue in our repo.