(function (root) { 'use strict'; function portions(value) { return Math.min(8, Math.max(1, Math.trunc(Number(value)) || 1)); } function nutrition(recipe, foods, count = 1) { return recipe.ingredients.reduce((sum, [id, grams]) => sum.map((v, i) => v + foods[id][i] * grams * portions(count) / 100), [0, 0, 0, 0]); } const api = { portions, nutrition }; if (typeof module !== 'undefined') module.exports = api; else root.RecipesCore = api; })(globalThis);