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

@tmlmt/cooklang-parser / Ingredient

Interface: Ingredient

Represents an ingredient in a recipe.

Properties

alternatives?

optional alternatives: Set<number>

The list of indexes of the ingredients mentioned in the preparation as alternatives to this ingredient


extras?

optional extras: IngredientExtras

The collection of potential additional metadata for the ingredient


flags?

optional flags: IngredientFlag[]

A list of potential state modifiers or other flags for the ingredient


name

name: string

The name of the ingredient.


preparation?

optional preparation: string

The preparation of the ingredient.


quantities?

optional quantities: (IngredientQuantityGroup | IngredientQuantityAndGroup)[]

Represents the quantities list for an ingredient as groups. Each group contains summed quantities that share the same alternative signature. Groups can be either simple (single unit) or AND groups (incompatible primary units with summed equivalents). Only populated for primary ingredients (not alternative-only). Quantities without alternatives are merged opportunistically when units are compatible. Quantities with alternatives are only merged if the alternatives are exactly the same.


usedAsPrimary?

optional usedAsPrimary: boolean

True if this ingredient appears as the primary choice (first in an alternatives list). Only primary ingredients have quantities populated directly.

Alternative-only ingredients (usedAsPrimary undefined/false) have their quantities available via the Recipe.choices structure.