@jclind/ingredient-parser 1.2.11 → 1.2.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.js CHANGED
@@ -13,9 +13,12 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
16
19
  Object.defineProperty(exports, "__esModule", { value: true });
17
20
  exports.parseIngredientString = exports.ingredientParser = void 0;
18
- const ingredientParser_1 = require("./src/funcs/ingredientParser");
21
+ const ingredientParser_1 = __importDefault(require("./src/funcs/ingredientParser"));
19
22
  exports.ingredientParser = ingredientParser_1.default;
20
23
  var parseIngredientString_1 = require("./src/funcs/parseIngredientString");
21
24
  Object.defineProperty(exports, "parseIngredientString", { enumerable: true, get: function () { return parseIngredientString_1.parseIngredientString; } });
@@ -1,8 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.createIngredientServerHttp = exports.spoonacularHttp = void 0;
4
- const axios_1 = require("axios");
5
- const DEFAULT_SERVER_URL = 'https://prepify-ingredients.up.railway.app';
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const DEFAULT_SERVER_URL = 'https://ingredient-parser-service-production-2635.up.railway.app';
6
9
  exports.spoonacularHttp = axios_1.default.create({
7
10
  baseURL: 'https://api.spoonacular.com/food/ingredients/',
8
11
  headers: {
@@ -8,6 +8,8 @@ const calculatePrice = (quantity, unit, price) => {
8
8
  const unitPrice = (_b = price.estimatedSingleUnitPrice) !== null && _b !== void 0 ? _b : 0;
9
9
  if (quantity === null)
10
10
  return unitPrice || null;
11
+ if (quantity === 0)
12
+ return 0;
11
13
  if (!unit)
12
14
  return (unitPrice * quantity) || null;
13
15
  let convertedUnit;
@@ -15,7 +17,7 @@ const calculatePrice = (quantity, unit, price) => {
15
17
  convertedUnit = (0, ingredient_unit_converter_1.converter)(quantity, unit);
16
18
  }
17
19
  catch (error) {
18
- return null;
20
+ return (unitPrice * quantity) || null;
19
21
  }
20
22
  if (!convertedUnit || 'error' in convertedUnit)
21
23
  return (unitPrice * quantity) || null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jclind/ingredient-parser",
3
- "version": "1.2.11",
3
+ "version": "1.2.12",
4
4
  "description": "Parses given sentence including ingredient information and attempts to return quantity, measurement and ingredient data",
5
5
  "keywords": [
6
6
  "recipe",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "homepage": "https://github.com/jclind/ingredient-parser#readme",
38
38
  "dependencies": {
39
- "@jclind/ingredient-unit-converter": "^1.0.6",
39
+ "@jclind/ingredient-unit-converter": "^1.1.0",
40
40
  "axios": "^1.0.0",
41
41
  "recipe-ingredient-parser-v3": "^1.5.0"
42
42
  },