@jclind/ingredient-parser 1.0.23 → 1.0.24
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/api/http.js +0 -1
- package/dist/api/requests.js +0 -1
- package/dist/funcs/calculatePrice.js +1 -1
- package/dist/funcs/editIngredientString.js +1 -2
- package/dist/funcs/getIngredientInfo.js +0 -1
- package/dist/funcs/getSpoonacularIngrData.js +0 -1
- package/dist/funcs/ingredientParser.js +1 -2
- package/dist/index.js +0 -1
- package/package.json +1 -1
package/dist/api/http.js
CHANGED
package/dist/api/requests.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//@ts-ignore
|
|
1
2
|
import { converter } from '@jclind/ingredient-unit-converter';
|
|
2
3
|
export const calculatePrice = (quantity, unit, price) => {
|
|
3
4
|
if (!quantity)
|
|
@@ -17,4 +18,3 @@ export const calculatePrice = (quantity, unit, price) => {
|
|
|
17
18
|
const total = convertedGrams * price.estimatedGramPrice;
|
|
18
19
|
return Math.ceil(total * 100) / 100;
|
|
19
20
|
};
|
|
20
|
-
//# sourceMappingURL=calculatePrice.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const editIngredientString = (ingrStr) => {
|
|
2
2
|
// Get string after first comment in ingredient string
|
|
3
3
|
let ingr = ingrStr.split(',')[0]?.trim() ?? ingrStr;
|
|
4
|
-
let comment = ingrStr.split(',')[1]?.trim() ??
|
|
4
|
+
let comment = ingrStr.split(',')[1]?.trim() ?? '';
|
|
5
5
|
const wordsToRemove = ['small', 'medium', 'large', 'fresh', 'canned'];
|
|
6
6
|
const regex = new RegExp('\\b(' + wordsToRemove.join('|') + ')\\b', 'gi');
|
|
7
7
|
const formattedIngrName = ingr
|
|
@@ -15,4 +15,3 @@ export const editIngredientString = (ingrStr) => {
|
|
|
15
15
|
.trim();
|
|
16
16
|
return { formattedIngrName, comment };
|
|
17
17
|
};
|
|
18
|
-
//# sourceMappingURL=editIngredientString.js.map
|
|
@@ -4,7 +4,7 @@ import { editIngredientString } from './editIngredientString.js';
|
|
|
4
4
|
import { getIngredientInfo } from './getIngredientInfo.js';
|
|
5
5
|
const ingredientParser = async (ingrString, spoonacularAPIKey) => {
|
|
6
6
|
const parsedIngr = parse(ingrString, 'eng');
|
|
7
|
-
const formattedIngr = editIngredientString(parsedIngr.ingredient);
|
|
7
|
+
const formattedIngr = editIngredientString(parsedIngr.ingredient ?? '');
|
|
8
8
|
const { formattedIngrName, comment } = formattedIngr;
|
|
9
9
|
const updatedParsedIngr = {
|
|
10
10
|
...parsedIngr,
|
|
@@ -48,4 +48,3 @@ const ingredientParser = async (ingrString, spoonacularAPIKey) => {
|
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
export default ingredientParser;
|
|
51
|
-
//# sourceMappingURL=ingredientParser.js.map
|
package/dist/index.js
CHANGED
package/package.json
CHANGED