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

@tmlmt/cooklang-parser / isAndGroup

Function: isAndGroup() ​

Call Signature ​

isAndGroup(x): x is IngredientQuantityAndGroup

Type guard to check if an ingredient quantity-like object is an AND group. *

Parameters ​

x ​

IngredientQuantityGroup | IngredientQuantityAndGroup | IngredientAlternativesOnlyGroup

The quantity-like entry to check

Returns ​

x is IngredientQuantityAndGroup

true if this is an AND group (has and property)

Example ​

typescript
for (const entry of ingredient.quantities) {
  if (isAndGroup(entry)) {
    // entry.and contains the list of quantities in the AND group
  }
}

Call Signature ​

isAndGroup(x): x is AndGroup

Type guard to check if an ingredient quantity-like object is an AND group. *

Parameters ​

x ​

QuantityWithUnitLike | Group

The quantity-like entry to check

Returns ​

x is AndGroup

true if this is an AND group (has and property)

Example ​

typescript
for (const entry of ingredient.quantities) {
  if (isAndGroup(entry)) {
    // entry.and contains the list of quantities in the AND group
  }
}