Interface ParseIngredientOptions

Options available to parseIngredient.

interface ParseIngredientOptions {
    additionalUOMs?: UnitOfMeasureDefinitions;
    allowLeadingOf?: boolean;
    ignoreUOMs?: string[];
    normalizeUOM?: boolean;
}

Properties

additionalUOMs?: UnitOfMeasureDefinitions

An object that matches the format of unitsOfMeasure. Keys that match any in unitsOfMeasure will be used instead of the default, and any others will be added to the list of known units of measure when parsing ingredients.

Default

{}
allowLeadingOf?: boolean

If true, ingredient descriptions that start with "of " will not be modified. (By default, a leading "of " will be removed from all descriptions.)

Default

false
ignoreUOMs?: string[]

An array of strings to ignore as units of measure when parsing ingredients.

Example

parseIngredient('2 small eggs', {
ignoreUOMs: ['small', 'medium', 'large']
})
// [
// {
// quantity: 2,
// quantity2: null,
// unitOfMeasure: null,
// unitOfMeasureID: null,
// description: 'small eggs',
// isGroupHeader: false,
// }
// ]

Default

[]
normalizeUOM?: boolean

Converts the unit of measure (unitOfMeasure property) of each ingredient to its long, singular form. For example, "ml" becomes "milliliter" and "cups" becomes "cup".

Default

false

Generated using TypeDoc