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

@tmlmt/cooklang-parser / formatQuantity

Function: formatQuantity()

formatQuantity(quantity): string

Format a quantity (fixed value or range) to a string.

Parameters

quantity

The quantity to format

FixedValue | Range

Returns

string

The formatted string representation

Example

typescript
formatQuantity({ type: "fixed", value: { type: "decimal", decimal: 100 } }); // "100"
formatQuantity({ type: "range", min: { type: "decimal", decimal: 1 }, max: { type: "decimal", decimal: 2 } }); // "1-2"