@tmlmt/cooklang-parser / isGroupedItem
Function: isGroupedItem()
isGroupedItem(
item):boolean
Check if an ingredient item is a grouped alternative (vs inline alternative).
Grouped alternatives are ingredients that share a group key (e.g., @|milk|...) and are distributed across multiple tokens in the recipe.
Parameters
item
The ingredient item to check
Returns
boolean
true if this is a grouped alternative
Example
typescript
for (const item of step.items) {
if (item.type === 'ingredient') {
if (isGroupedItem(item)) {
// Handle grouped alternative (e.g., show with strikethrough if not selected)
} else {
// Handle inline alternative (e.g., hide if not selected)
}
}
}