@tmlmt/cooklang-parser 3.0.0-alpha.11 → 3.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +66 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -19
- package/dist/index.d.ts +16 -19
- package/dist/index.js +66 -48
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -508,31 +508,27 @@ interface Ingredient {
|
|
|
508
508
|
/** The collection of potential additional metadata for the ingredient */
|
|
509
509
|
extras?: IngredientExtras;
|
|
510
510
|
}
|
|
511
|
-
|
|
512
|
-
* Represents a contributor to an ingredient's total quantity, corresponding
|
|
513
|
-
* to a single mention in the recipe text. It can contain multiple
|
|
514
|
-
* equivalent quantities (e.g., in different units).
|
|
515
|
-
* @category Types
|
|
516
|
-
*/
|
|
517
|
-
interface IngredientItemQuantity extends QuantityWithExtendedUnit {
|
|
518
|
-
/**
|
|
519
|
-
* A list of equivalent quantities/units for this ingredient mention besides the primary quantity.
|
|
520
|
-
* For `@salt{1%tsp|5%g}`, the main quantity is 1 tsp and the equivalents will contain 5 g.
|
|
521
|
-
*/
|
|
522
|
-
equivalents?: QuantityWithExtendedUnit[];
|
|
511
|
+
type MaybeScalableQuantity = QuantityWithExtendedUnit & {
|
|
523
512
|
/** Indicates whether this quantity should be scaled when the recipe serving size changes. */
|
|
524
513
|
scalable: boolean;
|
|
525
|
-
|
|
514
|
+
/** A list of equivalent quantities/units for this ingredient mention besides the primary quantity.
|
|
515
|
+
* For `@salt{1%tsp|5%g}`, the main quantity is 1 tsp and the equivalents will contain 5 g. */
|
|
516
|
+
equivalents?: QuantityWithExtendedUnit[];
|
|
517
|
+
};
|
|
518
|
+
type WithOptionalQuantity<T> = (T & MaybeScalableQuantity) | (T & {
|
|
519
|
+
quantity?: undefined;
|
|
520
|
+
scalable?: never;
|
|
521
|
+
unit?: never;
|
|
522
|
+
equivalents?: never;
|
|
523
|
+
});
|
|
526
524
|
/**
|
|
527
525
|
* Represents a single ingredient choice within a single or a group of `IngredientItem`s. It points
|
|
528
526
|
* to a specific ingredient and its corresponding quantity information.
|
|
529
527
|
* @category Types
|
|
530
528
|
*/
|
|
531
|
-
|
|
529
|
+
type IngredientAlternativeBase = {
|
|
532
530
|
/** The index of the ingredient within the {@link Recipe.ingredients} array. */
|
|
533
531
|
index: number;
|
|
534
|
-
/** The quantity of this specific mention of the ingredient */
|
|
535
|
-
itemQuantity?: IngredientItemQuantity;
|
|
536
532
|
/** The alias/name of the ingredient as it should be displayed for this occurrence. */
|
|
537
533
|
displayName: string;
|
|
538
534
|
/** An optional note for this specific choice (e.g., "for a vegan version"). */
|
|
@@ -541,7 +537,8 @@ interface IngredientAlternative {
|
|
|
541
537
|
* with group keys: the id of the corresponding ingredient item (e.g. "ingredient-item-2").
|
|
542
538
|
* Can be useful for creating alternative selection UI elements with anchor links */
|
|
543
539
|
itemId?: string;
|
|
544
|
-
}
|
|
540
|
+
};
|
|
541
|
+
type IngredientAlternative = WithOptionalQuantity<IngredientAlternativeBase>;
|
|
545
542
|
/**
|
|
546
543
|
* Represents an ingredient item in a recipe step.
|
|
547
544
|
* @category Types
|
|
@@ -1500,7 +1497,7 @@ declare function formatExtendedQuantity(item: QuantityWithExtendedUnit): string;
|
|
|
1500
1497
|
* formatItemQuantity(itemQuantity, " / "); // "100 g / 3.5 oz"
|
|
1501
1498
|
* ```
|
|
1502
1499
|
*/
|
|
1503
|
-
declare function formatItemQuantity(itemQuantity:
|
|
1500
|
+
declare function formatItemQuantity(itemQuantity: MaybeScalableQuantity, separator?: string): string;
|
|
1504
1501
|
/**
|
|
1505
1502
|
* Check if an ingredient item is a grouped alternative (vs inline alternative).
|
|
1506
1503
|
*
|
|
@@ -1642,4 +1639,4 @@ declare class NoShoppingListForCartError extends Error {
|
|
|
1642
1639
|
constructor();
|
|
1643
1640
|
}
|
|
1644
1641
|
|
|
1645
|
-
export { type AddedIngredient, type AddedRecipe, type AddedRecipeOptions, type AlternativeIngredientRef, type AndGroup, type ArbitraryScalable, type ArbitraryScalableItem, type CartContent, type CartMatch, type CartMisMatch, type CategorizedIngredients, type Category, CategoryConfig, type CategoryIngredient, type Cookware, type CookwareFlag, type CookwareItem, type DecimalValue, type FixedNumericValue, type FixedValue, type FlatAndGroup, type FlatGroup, type FlatOrGroup, type FractionValue, type GetIngredientQuantitiesOptions, type Group, type Ingredient, type IngredientAlternative, type IngredientExtras, type IngredientFlag, type IngredientItem, type
|
|
1642
|
+
export { type AddedIngredient, type AddedRecipe, type AddedRecipeOptions, type AlternativeIngredientRef, type AndGroup, type ArbitraryScalable, type ArbitraryScalableItem, type CartContent, type CartMatch, type CartMisMatch, type CategorizedIngredients, type Category, CategoryConfig, type CategoryIngredient, type Cookware, type CookwareFlag, type CookwareItem, type DecimalValue, type FixedNumericValue, type FixedValue, type FlatAndGroup, type FlatGroup, type FlatOrGroup, type FractionValue, type GetIngredientQuantitiesOptions, type Group, type Ingredient, type IngredientAlternative, type IngredientExtras, type IngredientFlag, type IngredientItem, type IngredientQuantityAndGroup, type IngredientQuantityGroup, type MaybeNestedAndGroup, type MaybeNestedGroup, type MaybeNestedOrGroup, type MaybeScalableQuantity, type Metadata, NoProductCatalogForCartError, type NoProductMatchErrorCode, NoShoppingListForCartError, type Note, type NoteItem, type OrGroup, ProductCatalog, type ProductMatch, type ProductMisMatch, type ProductOption, type ProductOptionBase, type ProductOptionCore, type ProductSelection, type ProductSize, type QuantityBase, type QuantityWithExtendedUnit, type QuantityWithPlainUnit, type QuantityWithUnitDef, type QuantityWithUnitLike, type Range, Recipe, type RecipeAlternatives, type RecipeChoices, type RecipeWithFactor, type RecipeWithServings, Section, ShoppingCart, type ShoppingCartOptions, type ShoppingCartSummary, ShoppingList, type SpecificUnitSystem, type Step, type StepItem, type TextItem, type TextValue, type Timer, type TimerItem, type ToBaseBySystem, type Unit, type UnitDefinition, type UnitDefinitionLike, type UnitSystem, type UnitType, convertQuantityToSystem, formatExtendedQuantity, formatItemQuantity, formatNumericValue, formatQuantity, formatQuantityWithUnit, formatSingleValue, formatUnit, hasAlternatives, isAlternativeSelected, isAndGroup, isGroupedItem, isSimpleGroup, renderFractionAsVulgar };
|
package/dist/index.d.ts
CHANGED
|
@@ -508,31 +508,27 @@ interface Ingredient {
|
|
|
508
508
|
/** The collection of potential additional metadata for the ingredient */
|
|
509
509
|
extras?: IngredientExtras;
|
|
510
510
|
}
|
|
511
|
-
|
|
512
|
-
* Represents a contributor to an ingredient's total quantity, corresponding
|
|
513
|
-
* to a single mention in the recipe text. It can contain multiple
|
|
514
|
-
* equivalent quantities (e.g., in different units).
|
|
515
|
-
* @category Types
|
|
516
|
-
*/
|
|
517
|
-
interface IngredientItemQuantity extends QuantityWithExtendedUnit {
|
|
518
|
-
/**
|
|
519
|
-
* A list of equivalent quantities/units for this ingredient mention besides the primary quantity.
|
|
520
|
-
* For `@salt{1%tsp|5%g}`, the main quantity is 1 tsp and the equivalents will contain 5 g.
|
|
521
|
-
*/
|
|
522
|
-
equivalents?: QuantityWithExtendedUnit[];
|
|
511
|
+
type MaybeScalableQuantity = QuantityWithExtendedUnit & {
|
|
523
512
|
/** Indicates whether this quantity should be scaled when the recipe serving size changes. */
|
|
524
513
|
scalable: boolean;
|
|
525
|
-
|
|
514
|
+
/** A list of equivalent quantities/units for this ingredient mention besides the primary quantity.
|
|
515
|
+
* For `@salt{1%tsp|5%g}`, the main quantity is 1 tsp and the equivalents will contain 5 g. */
|
|
516
|
+
equivalents?: QuantityWithExtendedUnit[];
|
|
517
|
+
};
|
|
518
|
+
type WithOptionalQuantity<T> = (T & MaybeScalableQuantity) | (T & {
|
|
519
|
+
quantity?: undefined;
|
|
520
|
+
scalable?: never;
|
|
521
|
+
unit?: never;
|
|
522
|
+
equivalents?: never;
|
|
523
|
+
});
|
|
526
524
|
/**
|
|
527
525
|
* Represents a single ingredient choice within a single or a group of `IngredientItem`s. It points
|
|
528
526
|
* to a specific ingredient and its corresponding quantity information.
|
|
529
527
|
* @category Types
|
|
530
528
|
*/
|
|
531
|
-
|
|
529
|
+
type IngredientAlternativeBase = {
|
|
532
530
|
/** The index of the ingredient within the {@link Recipe.ingredients} array. */
|
|
533
531
|
index: number;
|
|
534
|
-
/** The quantity of this specific mention of the ingredient */
|
|
535
|
-
itemQuantity?: IngredientItemQuantity;
|
|
536
532
|
/** The alias/name of the ingredient as it should be displayed for this occurrence. */
|
|
537
533
|
displayName: string;
|
|
538
534
|
/** An optional note for this specific choice (e.g., "for a vegan version"). */
|
|
@@ -541,7 +537,8 @@ interface IngredientAlternative {
|
|
|
541
537
|
* with group keys: the id of the corresponding ingredient item (e.g. "ingredient-item-2").
|
|
542
538
|
* Can be useful for creating alternative selection UI elements with anchor links */
|
|
543
539
|
itemId?: string;
|
|
544
|
-
}
|
|
540
|
+
};
|
|
541
|
+
type IngredientAlternative = WithOptionalQuantity<IngredientAlternativeBase>;
|
|
545
542
|
/**
|
|
546
543
|
* Represents an ingredient item in a recipe step.
|
|
547
544
|
* @category Types
|
|
@@ -1500,7 +1497,7 @@ declare function formatExtendedQuantity(item: QuantityWithExtendedUnit): string;
|
|
|
1500
1497
|
* formatItemQuantity(itemQuantity, " / "); // "100 g / 3.5 oz"
|
|
1501
1498
|
* ```
|
|
1502
1499
|
*/
|
|
1503
|
-
declare function formatItemQuantity(itemQuantity:
|
|
1500
|
+
declare function formatItemQuantity(itemQuantity: MaybeScalableQuantity, separator?: string): string;
|
|
1504
1501
|
/**
|
|
1505
1502
|
* Check if an ingredient item is a grouped alternative (vs inline alternative).
|
|
1506
1503
|
*
|
|
@@ -1642,4 +1639,4 @@ declare class NoShoppingListForCartError extends Error {
|
|
|
1642
1639
|
constructor();
|
|
1643
1640
|
}
|
|
1644
1641
|
|
|
1645
|
-
export { type AddedIngredient, type AddedRecipe, type AddedRecipeOptions, type AlternativeIngredientRef, type AndGroup, type ArbitraryScalable, type ArbitraryScalableItem, type CartContent, type CartMatch, type CartMisMatch, type CategorizedIngredients, type Category, CategoryConfig, type CategoryIngredient, type Cookware, type CookwareFlag, type CookwareItem, type DecimalValue, type FixedNumericValue, type FixedValue, type FlatAndGroup, type FlatGroup, type FlatOrGroup, type FractionValue, type GetIngredientQuantitiesOptions, type Group, type Ingredient, type IngredientAlternative, type IngredientExtras, type IngredientFlag, type IngredientItem, type
|
|
1642
|
+
export { type AddedIngredient, type AddedRecipe, type AddedRecipeOptions, type AlternativeIngredientRef, type AndGroup, type ArbitraryScalable, type ArbitraryScalableItem, type CartContent, type CartMatch, type CartMisMatch, type CategorizedIngredients, type Category, CategoryConfig, type CategoryIngredient, type Cookware, type CookwareFlag, type CookwareItem, type DecimalValue, type FixedNumericValue, type FixedValue, type FlatAndGroup, type FlatGroup, type FlatOrGroup, type FractionValue, type GetIngredientQuantitiesOptions, type Group, type Ingredient, type IngredientAlternative, type IngredientExtras, type IngredientFlag, type IngredientItem, type IngredientQuantityAndGroup, type IngredientQuantityGroup, type MaybeNestedAndGroup, type MaybeNestedGroup, type MaybeNestedOrGroup, type MaybeScalableQuantity, type Metadata, NoProductCatalogForCartError, type NoProductMatchErrorCode, NoShoppingListForCartError, type Note, type NoteItem, type OrGroup, ProductCatalog, type ProductMatch, type ProductMisMatch, type ProductOption, type ProductOptionBase, type ProductOptionCore, type ProductSelection, type ProductSize, type QuantityBase, type QuantityWithExtendedUnit, type QuantityWithPlainUnit, type QuantityWithUnitDef, type QuantityWithUnitLike, type Range, Recipe, type RecipeAlternatives, type RecipeChoices, type RecipeWithFactor, type RecipeWithServings, Section, ShoppingCart, type ShoppingCartOptions, type ShoppingCartSummary, ShoppingList, type SpecificUnitSystem, type Step, type StepItem, type TextItem, type TextValue, type Timer, type TimerItem, type ToBaseBySystem, type Unit, type UnitDefinition, type UnitDefinitionLike, type UnitSystem, type UnitType, convertQuantityToSystem, formatExtendedQuantity, formatItemQuantity, formatNumericValue, formatQuantity, formatQuantityWithUnit, formatSingleValue, formatUnit, hasAlternatives, isAlternativeSelected, isAndGroup, isGroupedItem, isSimpleGroup, renderFractionAsVulgar };
|
package/dist/index.js
CHANGED
|
@@ -2235,7 +2235,7 @@ var _Recipe = class _Recipe {
|
|
|
2235
2235
|
alternative.note = note;
|
|
2236
2236
|
}
|
|
2237
2237
|
if (itemQuantity) {
|
|
2238
|
-
alternative
|
|
2238
|
+
Object.assign(alternative, itemQuantity);
|
|
2239
2239
|
}
|
|
2240
2240
|
alternatives.push(alternative);
|
|
2241
2241
|
testString = groups.ingredientAlternative || "";
|
|
@@ -2343,7 +2343,7 @@ var _Recipe = class _Recipe {
|
|
|
2343
2343
|
displayName
|
|
2344
2344
|
};
|
|
2345
2345
|
if (itemQuantity) {
|
|
2346
|
-
alternative
|
|
2346
|
+
Object.assign(alternative, itemQuantity);
|
|
2347
2347
|
}
|
|
2348
2348
|
const existingAlternatives = this.choices.ingredientGroups.get(groupKey);
|
|
2349
2349
|
function upsertAlternativeToIngredient(ingredients, ingredientIdx, newAlternativeIdx) {
|
|
@@ -2479,28 +2479,28 @@ var _Recipe = class _Recipe {
|
|
|
2479
2479
|
for (const alt of allAlts) {
|
|
2480
2480
|
referencedIndices.add(alt.index);
|
|
2481
2481
|
}
|
|
2482
|
-
if (!alternative.
|
|
2482
|
+
if (!alternative.quantity) continue;
|
|
2483
2483
|
const baseQty = {
|
|
2484
|
-
quantity: alternative.
|
|
2485
|
-
...alternative.
|
|
2486
|
-
unit: alternative.
|
|
2484
|
+
quantity: alternative.quantity,
|
|
2485
|
+
...alternative.unit && {
|
|
2486
|
+
unit: alternative.unit
|
|
2487
2487
|
}
|
|
2488
2488
|
};
|
|
2489
|
-
const quantityEntry = alternative.
|
|
2489
|
+
const quantityEntry = alternative.equivalents?.length ? { or: [baseQty, ...alternative.equivalents] } : baseQty;
|
|
2490
2490
|
let alternativeRefs;
|
|
2491
2491
|
if (!hasExplicitChoice && allAlts.length > 1) {
|
|
2492
2492
|
alternativeRefs = allAlts.filter(
|
|
2493
2493
|
(alt) => isGrouped ? alt.itemId !== item.id : alt.index !== alternative.index
|
|
2494
2494
|
).map((otherAlt) => {
|
|
2495
2495
|
const ref = { index: otherAlt.index };
|
|
2496
|
-
if (otherAlt.
|
|
2496
|
+
if (otherAlt.quantity) {
|
|
2497
2497
|
const altQty = {
|
|
2498
|
-
quantity: otherAlt.
|
|
2499
|
-
...otherAlt.
|
|
2500
|
-
unit: otherAlt.
|
|
2498
|
+
quantity: otherAlt.quantity,
|
|
2499
|
+
...otherAlt.unit && {
|
|
2500
|
+
unit: otherAlt.unit.name
|
|
2501
2501
|
},
|
|
2502
|
-
...otherAlt.
|
|
2503
|
-
equivalents: otherAlt.
|
|
2502
|
+
...otherAlt.equivalents && {
|
|
2503
|
+
equivalents: otherAlt.equivalents.map(
|
|
2504
2504
|
(eq) => toPlainUnit(eq)
|
|
2505
2505
|
)
|
|
2506
2506
|
}
|
|
@@ -2513,14 +2513,10 @@ var _Recipe = class _Recipe {
|
|
|
2513
2513
|
const altIndices = getAlternativeSignature(alternativeRefs) ?? "";
|
|
2514
2514
|
let signature;
|
|
2515
2515
|
if (isGrouped) {
|
|
2516
|
-
const resolvedUnit = resolveUnit(
|
|
2517
|
-
alternative.itemQuantity.unit?.name
|
|
2518
|
-
);
|
|
2516
|
+
const resolvedUnit = resolveUnit(alternative.unit?.name);
|
|
2519
2517
|
signature = `group:${item.group}|${altIndices}|${resolvedUnit.type}`;
|
|
2520
2518
|
} else if (altIndices) {
|
|
2521
|
-
const resolvedUnit = resolveUnit(
|
|
2522
|
-
alternative.itemQuantity.unit?.name
|
|
2523
|
-
);
|
|
2519
|
+
const resolvedUnit = resolveUnit(alternative.unit?.name);
|
|
2524
2520
|
signature = `${altIndices}|${resolvedUnit.type}}`;
|
|
2525
2521
|
} else {
|
|
2526
2522
|
signature = null;
|
|
@@ -2788,16 +2784,16 @@ var _Recipe = class _Recipe {
|
|
|
2788
2784
|
const unitSystem = this.unitSystem;
|
|
2789
2785
|
function scaleAlternativesBy(alternatives, factor2) {
|
|
2790
2786
|
for (const alternative of alternatives) {
|
|
2791
|
-
if (alternative.
|
|
2792
|
-
const scaleFactor = alternative.
|
|
2793
|
-
if (alternative.
|
|
2794
|
-
alternative.
|
|
2795
|
-
alternative.
|
|
2787
|
+
if (alternative.quantity) {
|
|
2788
|
+
const scaleFactor = alternative.scalable ? Big4(factor2) : 1;
|
|
2789
|
+
if (alternative.quantity.type !== "fixed" || alternative.quantity.value.type !== "text") {
|
|
2790
|
+
alternative.quantity = multiplyQuantityValue(
|
|
2791
|
+
alternative.quantity,
|
|
2796
2792
|
scaleFactor
|
|
2797
2793
|
);
|
|
2798
2794
|
}
|
|
2799
|
-
if (alternative.
|
|
2800
|
-
alternative.
|
|
2795
|
+
if (alternative.equivalents) {
|
|
2796
|
+
alternative.equivalents = alternative.equivalents.map(
|
|
2801
2797
|
(altQuantity) => {
|
|
2802
2798
|
if (altQuantity.quantity.type === "fixed" && altQuantity.quantity.value.type === "text") {
|
|
2803
2799
|
return altQuantity;
|
|
@@ -2815,15 +2811,15 @@ var _Recipe = class _Recipe {
|
|
|
2815
2811
|
}
|
|
2816
2812
|
const optimizedPrimary = applyBestUnit(
|
|
2817
2813
|
{
|
|
2818
|
-
quantity: alternative.
|
|
2819
|
-
unit: alternative.
|
|
2814
|
+
quantity: alternative.quantity,
|
|
2815
|
+
unit: alternative.unit
|
|
2820
2816
|
},
|
|
2821
2817
|
unitSystem
|
|
2822
2818
|
);
|
|
2823
|
-
alternative.
|
|
2824
|
-
alternative.
|
|
2825
|
-
if (alternative.
|
|
2826
|
-
alternative.
|
|
2819
|
+
alternative.quantity = optimizedPrimary.quantity;
|
|
2820
|
+
alternative.unit = optimizedPrimary.unit;
|
|
2821
|
+
if (alternative.equivalents) {
|
|
2822
|
+
alternative.equivalents = alternative.equivalents.map(
|
|
2827
2823
|
(eq) => applyBestUnit(eq, unitSystem)
|
|
2828
2824
|
);
|
|
2829
2825
|
}
|
|
@@ -2927,18 +2923,27 @@ var _Recipe = class _Recipe {
|
|
|
2927
2923
|
}
|
|
2928
2924
|
return newPrimary;
|
|
2929
2925
|
}
|
|
2930
|
-
function
|
|
2931
|
-
const primaryUnit = resolveUnit(
|
|
2932
|
-
const equivalents =
|
|
2926
|
+
function convertAlternativeQuantity(alternative) {
|
|
2927
|
+
const primaryUnit = resolveUnit(alternative.unit?.name);
|
|
2928
|
+
const equivalents = alternative.equivalents ?? [];
|
|
2933
2929
|
const oldPrimary = {
|
|
2934
|
-
quantity:
|
|
2935
|
-
unit:
|
|
2930
|
+
quantity: alternative.quantity,
|
|
2931
|
+
unit: alternative.unit
|
|
2936
2932
|
};
|
|
2937
2933
|
if (primaryUnit.type !== "other" && isUnitCompatibleWithSystem(primaryUnit, system)) {
|
|
2938
2934
|
if (method === "remove") {
|
|
2939
|
-
return {
|
|
2935
|
+
return {
|
|
2936
|
+
quantity: alternative.quantity,
|
|
2937
|
+
unit: alternative.unit,
|
|
2938
|
+
scalable: alternative.scalable
|
|
2939
|
+
};
|
|
2940
2940
|
}
|
|
2941
|
-
return
|
|
2941
|
+
return {
|
|
2942
|
+
quantity: alternative.quantity,
|
|
2943
|
+
unit: alternative.unit,
|
|
2944
|
+
scalable: alternative.scalable,
|
|
2945
|
+
equivalents
|
|
2946
|
+
};
|
|
2942
2947
|
}
|
|
2943
2948
|
const targetEquivIndex = equivalents.findIndex((eq) => {
|
|
2944
2949
|
const eqUnit = resolveUnit(eq.unit?.name);
|
|
@@ -2953,7 +2958,7 @@ var _Recipe = class _Recipe {
|
|
|
2953
2958
|
targetEquiv,
|
|
2954
2959
|
oldPrimary,
|
|
2955
2960
|
remainingEquivalents,
|
|
2956
|
-
|
|
2961
|
+
alternative.scalable,
|
|
2957
2962
|
targetEquiv.unit?.integerProtected,
|
|
2958
2963
|
"swapped"
|
|
2959
2964
|
);
|
|
@@ -2964,8 +2969,8 @@ var _Recipe = class _Recipe {
|
|
|
2964
2969
|
converted,
|
|
2965
2970
|
oldPrimary,
|
|
2966
2971
|
equivalents,
|
|
2967
|
-
|
|
2968
|
-
|
|
2972
|
+
alternative.scalable,
|
|
2973
|
+
alternative.unit?.integerProtected,
|
|
2969
2974
|
"swapped"
|
|
2970
2975
|
);
|
|
2971
2976
|
}
|
|
@@ -2978,24 +2983,37 @@ var _Recipe = class _Recipe {
|
|
|
2978
2983
|
convertedEquiv,
|
|
2979
2984
|
oldPrimary,
|
|
2980
2985
|
remainingEquivalents,
|
|
2981
|
-
|
|
2986
|
+
alternative.scalable,
|
|
2982
2987
|
equiv.unit?.integerProtected,
|
|
2983
2988
|
"converted"
|
|
2984
2989
|
);
|
|
2985
2990
|
}
|
|
2986
2991
|
}
|
|
2987
2992
|
if (method === "remove") {
|
|
2988
|
-
return {
|
|
2993
|
+
return {
|
|
2994
|
+
quantity: alternative.quantity,
|
|
2995
|
+
unit: alternative.unit,
|
|
2996
|
+
scalable: alternative.scalable
|
|
2997
|
+
};
|
|
2989
2998
|
} else {
|
|
2990
|
-
return
|
|
2999
|
+
return {
|
|
3000
|
+
quantity: alternative.quantity,
|
|
3001
|
+
unit: alternative.unit,
|
|
3002
|
+
scalable: alternative.scalable,
|
|
3003
|
+
equivalents
|
|
3004
|
+
};
|
|
2991
3005
|
}
|
|
2992
3006
|
}
|
|
2993
3007
|
function convertAlternatives(alternatives) {
|
|
2994
3008
|
for (const alternative of alternatives) {
|
|
2995
|
-
if (alternative.
|
|
2996
|
-
|
|
2997
|
-
alternative
|
|
3009
|
+
if (alternative.quantity) {
|
|
3010
|
+
const converted = convertAlternativeQuantity(
|
|
3011
|
+
alternative
|
|
2998
3012
|
);
|
|
3013
|
+
alternative.quantity = converted.quantity;
|
|
3014
|
+
alternative.unit = converted.unit;
|
|
3015
|
+
alternative.scalable = converted.scalable;
|
|
3016
|
+
alternative.equivalents = converted.equivalents;
|
|
2999
3017
|
}
|
|
3000
3018
|
}
|
|
3001
3019
|
}
|