@jlucaspains/sharp-recipe-parser
Version:
Recipe parsing tools
27 lines • 1.11 kB
TypeScript
/**
* Parses an ingredient string into its component parts
* @param {string} text - The ingredient string to be parsed.
* @param {Types.ValidLanguages} language - The language of the ingredient string.
* @param {ParseIngredientOptions} options - The options to use when parsing the ingredient string.
* @returns {IngredientParseResult | null} The parsed ingredient object, or null if the ingredient string is empty.
* @throws {Error} if language is not supported
*/
export function parseIngredient(text: string, language: Types.ValidLanguages, options?: ParseIngredientOptions): IngredientParseResult | null;
export type IngredientParseResult = {
quantity: number;
quantityText: string;
minQuantity: number;
maxQuantity: number;
unit: string;
unitText: string;
ingredient: string;
extra: string;
alternativeQuantities: Types.AlternativeQuantity[];
};
export type ParseIngredientOptions = {
includeExtra: boolean;
includeAlternativeUnits: boolean;
fallbackLanguage: string;
};
import * as Types from "./types.js";
//# sourceMappingURL=ingredientParser.d.ts.map