ingredient-math
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -30,3 +30,4 @@ import { parse } from 'recipe-ingredient-parser'; | ||
export var convertIngredient = function convertIngredient(ingString, servingFactor) { | ||
var parsedIng = getParsedIngredient(ingString); | ||
//const parsedIng = getParsedIngredient(ingString); | ||
var parsedIng = parse(ingString.toLowerCase()); | ||
var quantity = parsedIng.quantity, | ||
@@ -42,23 +43,21 @@ unit = parsedIng.unit, | ||
}; | ||
}; | ||
export var getParsedIngredient = function getParsedIngredient(ingString) { | ||
var parsedIng = parse(ingString.toLowerCase()); | ||
var quantity = parsedIng.quantity, | ||
unit = parsedIng.unit, | ||
ingredient = parsedIng.ingredient; | ||
var parsedQuantity = parseInt(quantity); | ||
var resultQuantity = parsedQuantity; | ||
if (!quantity) resultQuantity = null; | ||
}; //export const getParsedIngredient = ingString => { | ||
//const parsedIng = parse(ingString.toLowerCase()); | ||
//console.log('PARSED', parsedIng); | ||
//const { quantity, unit, ingredient } = parsedIng; | ||
//const parsedQuantity = parseInt(quantity); | ||
//var resultQuantity = parsedQuantity; | ||
//if (!quantity) { | ||
////pinch of salt | ||
//resultQuantity = null; | ||
//} else if (!parsedQuantity) { | ||
//resultQuantity = quantity; | ||
//} | ||
//return { | ||
//quantity: resultQuantity, | ||
//unit, | ||
//ingredient, | ||
//}; | ||
//}; | ||
if (!parsedQuantity) { | ||
resultQuantity = quantity; | ||
} | ||
return { | ||
quantity: resultQuantity, | ||
unit: unit, | ||
ingredient: ingredient | ||
}; | ||
}; | ||
var maybePluralizeUnit = function maybePluralizeUnit(quantity, unit) { | ||
@@ -76,3 +75,3 @@ if (!quantity) return unit; | ||
if (!quantity) return null; | ||
var newQuantity = parseInt(quantity) * serving; | ||
var newQuantity = parseFloat(quantity) * serving; | ||
var newQuantityType = getQuantityType(newQuantity); | ||
@@ -110,3 +109,3 @@ var quantityType = getQuantityType(quantity); | ||
var createFraction = function createFraction(val) { | ||
return new Fraction(parseInt(val)).simplify(); | ||
return new Fraction(parseFloat(val)).simplify(); | ||
}; | ||
@@ -113,0 +112,0 @@ /** |
{ | ||
"name": "ingredient-math", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Library for converting ingredients based on serving size changes", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5161
108