⚠️ This is pre-release documentation for v3. For stable docs, visit v2.
Skip to content

@tmlmt/cooklang-parser / convertQuantityToSystem

Function: convertQuantityToSystem()

Call Signature

convertQuantityToSystem(quantity, system): QuantityWithPlainUnit | undefined

Converts a quantity to the best unit in a target system. Returns the converted quantity, or undefined if the unit type is "other" or not convertible.

Parameters

quantity

QuantityWithPlainUnit

The quantity to convert

system

SpecificUnitSystem

The target unit system

Returns

QuantityWithPlainUnit | undefined

The converted quantity, or undefined if conversion not possible

Call Signature

convertQuantityToSystem(quantity, system): QuantityWithExtendedUnit | undefined

Converts a quantity to the best unit in a target system. Returns the converted quantity, or undefined if the unit type is "other" or not convertible.

Parameters

quantity

QuantityWithExtendedUnit

The quantity to convert

system

SpecificUnitSystem

The target unit system

Returns

QuantityWithExtendedUnit | undefined

The converted quantity, or undefined if conversion not possible