36 lines
851 B
TypeScript
36 lines
851 B
TypeScript
import { parseIngredient as _parseIngredient } from "https://esm.sh/parse-ingredient@1.0.1";
|
|
|
|
export function parseIngredient(text: string) {
|
|
const ing = _parseIngredient(text, {
|
|
additionalUOMs: {
|
|
tableSpoon: {
|
|
short: "EL",
|
|
plural: "Table Spoons",
|
|
alternates: ["el", "EL", "Tbsp", "tbsp"],
|
|
},
|
|
teaSpoon: {
|
|
short: "TL",
|
|
plural: "Tea Spoon",
|
|
alternates: ["tl", "TL", "Tsp", "tsp", "teaspoon"],
|
|
},
|
|
litre: {
|
|
short: "L",
|
|
plural: "liters",
|
|
alternates: ["L", "l"],
|
|
},
|
|
paket: {
|
|
short: "Paket",
|
|
plural: "Pakets",
|
|
alternates: ["Paket", "paket"],
|
|
},
|
|
},
|
|
});
|
|
|
|
return {
|
|
name: ing[0].description,
|
|
unit: ing[0].unitOfMeasure || "",
|
|
quantity: ing[0].quantity?.toString() || "",
|
|
note: "",
|
|
};
|
|
}
|