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

@tmlmt/cooklang-parser / formatSingleValue

Function: formatSingleValue()

formatSingleValue(value): string

Format a single value (text, decimal, or fraction) to a string.

Parameters

value

The value to format

DecimalValue | FractionValue | TextValue

Returns

string

The formatted string representation

Example

typescript
formatSingleValue({ type: "text", text: "a pinch" }); // "a pinch"
formatSingleValue({ type: "decimal", decimal: 2 }); // "2"
formatSingleValue({ type: "fraction", num: 3, den: 4 }); // "3/4"