@jclind/ingredient-parser 1.0.34 → 1.0.35

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 CHANGED
@@ -1,11 +1,14 @@
1
- import axios from 'axios';
2
- export const mongoHttp = axios.create({
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.spoonacularHttp = exports.mongoHttp = void 0;
4
+ const axios_1 = require("axios");
5
+ exports.mongoHttp = axios_1.default.create({
3
6
  baseURL: 'https://us-east-1.aws.data.mongodb-api.com/app/prepify-ixumn/endpoint',
4
7
  headers: {
5
8
  'Content-type': 'application/json',
6
9
  },
7
10
  });
8
- export const spoonacularHttp = axios.create({
11
+ exports.spoonacularHttp = axios_1.default.create({
9
12
  baseURL: 'https://api.spoonacular.com/food/ingredients/',
10
13
  headers: {
11
14
  'Content-type': 'application/json',
@@ -1,4 +1,5 @@
1
+ import { IngredientData } from '../../index.js';
1
2
  export declare const checkIngredient: (name: string) => Promise<import("axios").AxiosResponse<any, any>>;
2
- export declare const searchIngredient: (name: string, spoonacularAPIKey: any) => Promise<any>;
3
- export declare const getIngredientInformation: (ingrId: number, unit: boolean, spoonacularAPIKey: any) => Promise<any>;
4
- export declare const setMongoDBIngrData: (data: any) => Promise<import("axios").AxiosResponse<any, any>>;
3
+ export declare const searchIngredient: (name: string, spoonacularAPIKey: string) => Promise<any>;
4
+ export declare const getIngredientInformation: (ingrId: number, unit: boolean, spoonacularAPIKey: string) => Promise<any>;
5
+ export declare const setMongoDBIngrData: (data: IngredientData) => Promise<import("axios").AxiosResponse<any, any>>;
@@ -1,11 +1,24 @@
1
- import { mongoHttp, spoonacularHttp } from './http.js';
2
- export const checkIngredient = async (name) => {
3
- return await mongoHttp.get(`checkIngredient?name=${name}`);
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
4
10
  };
5
- export const searchIngredient = async (name, spoonacularAPIKey) => {
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.setMongoDBIngrData = exports.getIngredientInformation = exports.searchIngredient = exports.checkIngredient = void 0;
13
+ const http_js_1 = require("./http.js");
14
+ const checkIngredient = (name) => __awaiter(void 0, void 0, void 0, function* () {
15
+ return yield http_js_1.mongoHttp.get(`checkIngredient?name=${name}`);
16
+ });
17
+ exports.checkIngredient = checkIngredient;
18
+ const searchIngredient = (name, spoonacularAPIKey) => __awaiter(void 0, void 0, void 0, function* () {
6
19
  let searchedIngr;
7
20
  try {
8
- searchedIngr = await spoonacularHttp.get(`search?query=${name}&number=1&apiKey=${spoonacularAPIKey}`);
21
+ searchedIngr = yield http_js_1.spoonacularHttp.get(`search?query=${name}&number=1&apiKey=${spoonacularAPIKey}`);
9
22
  }
10
23
  catch (error) {
11
24
  const res = error.response.data;
@@ -17,11 +30,12 @@ export const searchIngredient = async (name, spoonacularAPIKey) => {
17
30
  }
18
31
  }
19
32
  return searchedIngr;
20
- };
21
- export const getIngredientInformation = async (ingrId, unit, spoonacularAPIKey) => {
33
+ });
34
+ exports.searchIngredient = searchIngredient;
35
+ const getIngredientInformation = (ingrId, unit, spoonacularAPIKey) => __awaiter(void 0, void 0, void 0, function* () {
22
36
  let ingrData;
23
37
  try {
24
- ingrData = await spoonacularHttp.get(`${ingrId}/information?amount=1&${unit ? 'unit=grams&' : ''}apiKey=${spoonacularAPIKey}`);
38
+ ingrData = yield http_js_1.spoonacularHttp.get(`${ingrId}/information?amount=1&${unit ? 'unit=grams&' : ''}apiKey=${spoonacularAPIKey}`);
25
39
  }
26
40
  catch (error) {
27
41
  const res = error.response.data;
@@ -33,7 +47,9 @@ export const getIngredientInformation = async (ingrId, unit, spoonacularAPIKey)
33
47
  }
34
48
  }
35
49
  return ingrData;
36
- };
37
- export const setMongoDBIngrData = async (data) => {
38
- return await mongoHttp.post(`addIngredient`, data);
39
- };
50
+ });
51
+ exports.getIngredientInformation = getIngredientInformation;
52
+ const setMongoDBIngrData = (data) => __awaiter(void 0, void 0, void 0, function* () {
53
+ return yield http_js_1.mongoHttp.post(`addIngredient`, data);
54
+ });
55
+ exports.setMongoDBIngrData = setMongoDBIngrData;
@@ -1,4 +1,4 @@
1
- export declare const calculatePrice: (quantity: number, unit: string, price: {
1
+ export declare const calculatePrice: (quantity: number | null, unit: string | null, price: {
2
2
  estimatedSingleUnitPrice: number;
3
3
  estimatedGramPrice: number;
4
4
  }) => number | null;
@@ -1,13 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculatePrice = void 0;
1
4
  //@ts-ignore
2
- import { converter } from '@jclind/ingredient-unit-converter';
3
- export const calculatePrice = (quantity, unit, price) => {
5
+ const ingredient_unit_converter_1 = require("@jclind/ingredient-unit-converter");
6
+ const calculatePrice = (quantity, unit, price) => {
4
7
  if (!quantity)
5
8
  return price.estimatedSingleUnitPrice;
6
9
  if (!unit)
7
10
  return price.estimatedSingleUnitPrice * quantity;
8
11
  let convertedUnit;
9
12
  try {
10
- convertedUnit = converter(quantity, unit);
13
+ convertedUnit = (0, ingredient_unit_converter_1.converter)(quantity, unit);
11
14
  }
12
15
  catch (error) {
13
16
  return null;
@@ -18,3 +21,4 @@ export const calculatePrice = (quantity, unit, price) => {
18
21
  const total = convertedGrams * price.estimatedGramPrice;
19
22
  return Math.ceil(total * 100) / 100;
20
23
  };
24
+ exports.calculatePrice = calculatePrice;
@@ -0,0 +1 @@
1
+ export declare const convertFractions: (str: string) => string;
@@ -1,4 +1,7 @@
1
- export const convertFractions = (str) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertFractions = void 0;
4
+ const convertFractions = (str) => {
2
5
  const fractions = {
3
6
  '¼': '1/4',
4
7
  '½': '1/2',
@@ -25,3 +28,4 @@ export const convertFractions = (str) => {
25
28
  }
26
29
  return str;
27
30
  };
31
+ exports.convertFractions = convertFractions;
@@ -1,15 +1,30 @@
1
- import { checkIngredient } from '../api/requests.js';
2
- import { getSpoonacularIngrData } from './getSpoonacularIngrData.js';
3
- export async function getIngredientInfo(ingrName, spoonacularAPIKey) {
4
- const ingrNameLower = ingrName.toLowerCase();
5
- if (!ingrNameLower)
6
- throw new Error('Ingredient Invalid');
7
- const mongoIngrData = await checkIngredient(ingrNameLower);
8
- if (!mongoIngrData.data) {
9
- const ingrData = await getSpoonacularIngrData(ingrNameLower, spoonacularAPIKey);
10
- return ingrData;
11
- }
12
- else {
13
- return mongoIngrData.data;
14
- }
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getIngredientInfo = void 0;
13
+ const requests_js_1 = require("../api/requests.js");
14
+ const getSpoonacularIngrData_js_1 = require("./getSpoonacularIngrData.js");
15
+ function getIngredientInfo(ingrName, spoonacularAPIKey) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const ingrNameLower = ingrName.toLowerCase();
18
+ if (!ingrNameLower)
19
+ throw new Error('Ingredient Invalid');
20
+ const mongoIngrData = yield (0, requests_js_1.checkIngredient)(ingrNameLower);
21
+ if (!mongoIngrData.data) {
22
+ const ingrData = yield (0, getSpoonacularIngrData_js_1.getSpoonacularIngrData)(ingrNameLower, spoonacularAPIKey);
23
+ return ingrData;
24
+ }
25
+ else {
26
+ return mongoIngrData.data;
27
+ }
28
+ });
15
29
  }
30
+ exports.getIngredientInfo = getIngredientInfo;
@@ -1,25 +1,36 @@
1
- import { getIngredientInformation, searchIngredient, setMongoDBIngrData, } from '../api/requests.js';
2
- export async function getSpoonacularIngrData(name, spoonacularAPIKey) {
3
- const searchedIngr = await searchIngredient(name, spoonacularAPIKey);
4
- if (searchedIngr.error)
5
- return searchedIngr;
6
- const ingrId = searchedIngr?.data?.results[0]?.id ?? null;
7
- if (!ingrId)
8
- throw new Error(`No Data Found, unknown ingredient: ${name}`);
9
- const ingrDataGram = await getIngredientInformation(ingrId, true, spoonacularAPIKey);
10
- const ingrDataSingleUnit = await getIngredientInformation(ingrId, false, spoonacularAPIKey);
11
- if (ingrDataGram.error || ingrDataSingleUnit.error)
12
- return ingrDataGram;
13
- const estimatedGramPrice = ingrDataGram.data.estimatedCost.value;
14
- const estimatedSingleUnitPrice = ingrDataSingleUnit.data.estimatedCost.value;
15
- const ingrData = {
16
- ...ingrDataGram.data,
17
- name,
18
- ingredientId: ingrId,
19
- estimatedPrices: { estimatedGramPrice, estimatedSingleUnitPrice },
20
- };
21
- const mongoDBIngrData = ingrData;
22
- const mongoRes = await setMongoDBIngrData(mongoDBIngrData);
23
- const _id = mongoRes.data.insertedId;
24
- return { ...mongoDBIngrData, _id };
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getSpoonacularIngrData = void 0;
13
+ const requests_js_1 = require("../api/requests.js");
14
+ function getSpoonacularIngrData(name, spoonacularAPIKey) {
15
+ var _a, _b, _c;
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ const searchedIngr = yield (0, requests_js_1.searchIngredient)(name, spoonacularAPIKey);
18
+ if (searchedIngr.error)
19
+ return searchedIngr;
20
+ const ingrId = (_c = (_b = (_a = searchedIngr === null || searchedIngr === void 0 ? void 0 : searchedIngr.data) === null || _a === void 0 ? void 0 : _a.results[0]) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : null;
21
+ if (!ingrId)
22
+ throw new Error(`No Data Found, unknown ingredient: ${name}`);
23
+ const ingrDataGram = yield (0, requests_js_1.getIngredientInformation)(ingrId, true, spoonacularAPIKey);
24
+ const ingrDataSingleUnit = yield (0, requests_js_1.getIngredientInformation)(ingrId, false, spoonacularAPIKey);
25
+ if (ingrDataGram.error || ingrDataSingleUnit.error)
26
+ return ingrDataGram;
27
+ const estimatedGramPrice = ingrDataGram.data.estimatedCost.value;
28
+ const estimatedSingleUnitPrice = ingrDataSingleUnit.data.estimatedCost.value;
29
+ const ingrData = Object.assign(Object.assign({}, ingrDataGram.data), { name, ingredientId: ingrId, estimatedPrices: { estimatedGramPrice, estimatedSingleUnitPrice } });
30
+ const mongoDBIngrData = ingrData;
31
+ const mongoRes = yield (0, requests_js_1.setMongoDBIngrData)(mongoDBIngrData);
32
+ const _id = mongoRes.data.insertedId;
33
+ return Object.assign(Object.assign({}, mongoDBIngrData), { _id });
34
+ });
25
35
  }
36
+ exports.getSpoonacularIngrData = getSpoonacularIngrData;
@@ -1,3 +1,3 @@
1
- import { IngredientResponse } from '../../types.js';
1
+ import { IngredientResponse } from '../../index.js';
2
2
  declare const ingredientParser: (ingrString: string, spoonacularAPIKey: string) => Promise<IngredientResponse>;
3
3
  export default ingredientParser;
@@ -1,29 +1,47 @@
1
- import { calculatePrice } from './calculatePrice.js';
2
- import { parseIngredientString } from './parseIngredientString.js';
3
- import { getIngredientInfo } from './getIngredientInfo.js';
4
- const ingredientParser = async (ingrString, spoonacularAPIKey) => {
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __rest = (this && this.__rest) || function (s, e) {
12
+ var t = {};
13
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
+ t[p] = s[p];
15
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
+ t[p[i]] = s[p[i]];
19
+ }
20
+ return t;
21
+ };
22
+ Object.defineProperty(exports, "__esModule", { value: true });
23
+ const calculatePrice_js_1 = require("./calculatePrice.js");
24
+ const parseIngredientString_js_1 = require("./parseIngredientString.js");
25
+ const getIngredientInfo_js_1 = require("./getIngredientInfo.js");
26
+ const ingredientParser = (ingrString, spoonacularAPIKey) => __awaiter(void 0, void 0, void 0, function* () {
5
27
  // const parsedIngr: ParsedIngredient = parse(ingrString, 'eng')
6
- const parsedIngr = parseIngredientString(ingrString);
28
+ const parsedIngr = (0, parseIngredientString_js_1.parseIngredientString)(ingrString);
7
29
  let ingrData = null;
8
30
  try {
9
- ingrData = await getIngredientInfo(parsedIngr.ingredient || '', spoonacularAPIKey);
31
+ ingrData = yield (0, getIngredientInfo_js_1.getIngredientInfo)(parsedIngr.ingredient || '', spoonacularAPIKey);
10
32
  }
11
33
  catch (error) {
12
34
  return {
13
35
  error: { message: error.message },
14
36
  ingredientData: null,
15
- parsedIngredient: parsedIngr ?? null,
37
+ parsedIngredient: parsedIngr !== null && parsedIngr !== void 0 ? parsedIngr : null,
16
38
  };
17
39
  }
18
40
  if (parsedIngr.ingredient && ingrData) {
19
- const { estimatedPrices, meta, categoryPath, unit, unitShort, unitLong, original, id, ...reducedIngrData } = ingrData;
20
- const totalPrice = calculatePrice(parsedIngr.quantity, parsedIngr.unit, estimatedPrices);
41
+ const { estimatedPrices, meta, categoryPath, unit, unitShort, unitLong, original, id } = ingrData, reducedIngrData = __rest(ingrData, ["estimatedPrices", "meta", "categoryPath", "unit", "unitShort", "unitLong", "original", "id"]);
42
+ const totalPrice = (0, calculatePrice_js_1.calculatePrice)(parsedIngr.quantity, parsedIngr.unit, estimatedPrices);
21
43
  const imagePath = `https://spoonacular.com/cdn/ingredients_100x100/${reducedIngrData.image}`;
22
- const updatedIngrData = {
23
- ...reducedIngrData,
24
- imagePath,
25
- totalPriceUSACents: totalPrice,
26
- };
44
+ const updatedIngrData = Object.assign(Object.assign({}, reducedIngrData), { imagePath, totalPriceUSACents: totalPrice });
27
45
  return {
28
46
  ingredientData: updatedIngrData,
29
47
  parsedIngredient: parsedIngr,
@@ -38,5 +56,5 @@ const ingredientParser = async (ingrString, spoonacularAPIKey) => {
38
56
  parsedIngredient: parsedIngr,
39
57
  };
40
58
  }
41
- };
42
- export default ingredientParser;
59
+ });
60
+ exports.default = ingredientParser;
@@ -0,0 +1,2 @@
1
+ import { ParsedIngredient } from '../../index.js';
2
+ export declare const parseIngredientString: (ingrStr: string) => ParsedIngredient;
@@ -1,11 +1,15 @@
1
- import { parse } from 'recipe-ingredient-parser-v3';
2
- import { convertFractions } from './convertFractions.js';
3
- export const parseIngredientString = (ingrStr) => {
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.parseIngredientString = void 0;
4
+ const recipe_ingredient_parser_v3_1 = require("recipe-ingredient-parser-v3");
5
+ const convertFractions_js_1 = require("./convertFractions.js");
6
+ const parseIngredientString = (ingrStr) => {
7
+ var _a, _b;
4
8
  // Define regular expressions for text inside parentheses and text before the first comma
5
9
  const parenRegex = /(\(.*?\))/;
6
10
  const commaRegex = /^(.*?)(?=,)/;
7
11
  // Extract the text inside the parentheses and the text before the first comma using regular expressions
8
- const parenthesesStr = ingrStr.match(parenRegex)?.[1] ?? '';
12
+ const parenthesesStr = (_b = (_a = ingrStr.match(parenRegex)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : '';
9
13
  const textWithoutParenthesesStr = ingrStr.replace(parenthesesStr, '');
10
14
  // Find the index of the first ',' character
11
15
  const commaIndex = textWithoutParenthesesStr.indexOf(',');
@@ -13,7 +17,7 @@ export const parseIngredientString = (ingrStr) => {
13
17
  let comment;
14
18
  // If there is no comma in the string don't include a comment
15
19
  if (commaIndex !== -1) {
16
- ingrText = convertFractions(textWithoutParenthesesStr
20
+ ingrText = (0, convertFractions_js_1.convertFractions)(textWithoutParenthesesStr
17
21
  .substring(0, commaIndex)
18
22
  .replace(parenRegex, '')
19
23
  .trim());
@@ -24,7 +28,7 @@ export const parseIngredientString = (ingrStr) => {
24
28
  parenthesesStr).trim();
25
29
  }
26
30
  else {
27
- ingrText = convertFractions(ingrStr.replace(parenRegex, '').trim());
31
+ ingrText = (0, convertFractions_js_1.convertFractions)(ingrStr.replace(parenRegex, '').trim());
28
32
  comment = parenthesesStr.trim();
29
33
  }
30
34
  const prepIngrText = ingrText.replace(/\b(lb|lbs)\b/g, match => {
@@ -36,9 +40,9 @@ export const parseIngredientString = (ingrStr) => {
36
40
  return 'pounds';
37
41
  }
38
42
  });
39
- const parsedIngrRes = parse(prepIngrText, 'eng');
43
+ const parsedIngrRes = (0, recipe_ingredient_parser_v3_1.parse)(prepIngrText, 'eng');
40
44
  if (!parsedIngrRes.ingredient) {
41
- return { ...parsedIngrRes, originalIngredientString: ingrStr, comment };
45
+ return Object.assign(Object.assign({}, parsedIngrRes), { originalIngredientString: ingrStr, comment });
42
46
  }
43
47
  const wordsToRemove = ['small', 'medium', 'large', 'fresh', 'canned'];
44
48
  const regex = new RegExp('\\b(' + wordsToRemove.join('|') + ')\\b', 'gi');
@@ -49,10 +53,6 @@ export const parseIngredientString = (ingrStr) => {
49
53
  .replace(/^(fluid|fl|oz) /, '') // Remove "fluid ", "fl ", or "oz " at the beginning of the string
50
54
  .replace(regex, '')
51
55
  .trim();
52
- return {
53
- ...parsedIngrRes,
54
- ingredient: formattedIngrName,
55
- originalIngredientString: ingrStr,
56
- comment,
57
- };
56
+ return Object.assign(Object.assign({}, parsedIngrRes), { ingredient: formattedIngrName, originalIngredientString: ingrStr, comment });
58
57
  };
58
+ exports.parseIngredientString = parseIngredientString;
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import ingredientParser from './funcs/ingredientParser.js';
2
- import { ParsedIngredient as ParsedIngredientType, IngredientData as IngredientDataType, IngredientResponse as IngredientResponseType } from '../types.js';
2
+ import { ParsedIngredient as ParsedIngredientType, IngredientData as IngredientDataType, IngredientResponse as IngredientResponseType } from '../index.js';
3
3
  export { ingredientParser, ParsedIngredientType, IngredientDataType, IngredientResponseType, };
package/dist/index.js CHANGED
@@ -1,2 +1,5 @@
1
- import ingredientParser from './funcs/ingredientParser.js';
2
- export { ingredientParser, };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ingredientParser = void 0;
4
+ const ingredientParser_js_1 = require("./funcs/ingredientParser.js");
5
+ exports.ingredientParser = ingredientParser_js_1.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jclind/ingredient-parser",
3
- "version": "1.0.34",
3
+ "version": "1.0.35",
4
4
  "description": "Parses given sentence including ingredient information and attemps to return quantity, measurement and ingredient data",
5
5
  "keywords": [
6
6
  "recipe",
@@ -1 +0,0 @@
1
- {"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/api/http.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC;IACpC,OAAO,EACL,uEAAuE;IACzE,OAAO,EAAE;QACP,cAAc,EAAE,kBAAkB;KACnC;CACF,CAAC,CAAA;AACF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,CAAC;IAC1C,OAAO,EAAE,+CAA+C;IACxD,OAAO,EAAE;QACP,cAAc,EAAE,kBAAkB;KACnC;CACF,CAAC,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"requests.js","sourceRoot":"","sources":["../../src/api/requests.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAEtD,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAAE,IAAY,EAAE,EAAE;IACpD,OAAO,MAAM,SAAS,CAAC,GAAG,CAAC,wBAAwB,IAAI,EAAE,CAAC,CAAA;AAC5D,CAAC,CAAA;AACD,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,EAAE,IAAY,EAAE,iBAAiB,EAAE,EAAE;IACxE,IAAI,YAAiB,CAAA;IACrB,IAAI;QACF,YAAY,GAAG,MAAM,eAAe,CAAC,GAAG,CACtC,gBAAgB,IAAI,oBAAoB,iBAAiB,EAAE,CAC5D,CAAA;KACF;IAAC,OAAO,KAAK,EAAE;QACd,MAAM,GAAG,GAAQ,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAA;QACpC,IAAI,GAAG,CAAC,IAAI,KAAK,GAAG,EAAE;YACpB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,OAAO,KAAK,CAAC,wBAAwB,GAAG,QAAQ,CAAA;IAE3D,IAAI,aAAa,CAAA;IACjB,IAAI;QACF,aAAa,GAAG,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;KAC1C;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,IAAI,CAAA;KACZ;IAED,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,KAAK;QACvC,OAAO,KAAK,CAAC,wBAAwB,GAAG,QAAQ,CAAA;IAElD,MAAM,cAAc,GAAG,MAAM,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;IACrD,MAAM,KAAK,GAAW,cAAc,GAAG,KAAK,CAAC,kBAAkB,CAAA;IAC/D,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,GAAG,CAAC,GAAG,GAAG,CAAA;AACrC,CAAC,CAAA"}
@@ -1,4 +0,0 @@
1
- export declare const editIngredientString: (ingrStr: string) => {
2
- formattedIngrName: string;
3
- comment: string;
4
- };
@@ -1,17 +0,0 @@
1
- export const editIngredientString = (ingrStr) => {
2
- // Get string after first comment in ingredient string
3
- let ingr = ingrStr.split(',')[0]?.trim() ?? ingrStr;
4
- let comment = ingrStr.split(',')[1]?.trim() ?? '';
5
- const wordsToRemove = ['small', 'medium', 'large', 'fresh', 'canned'];
6
- const regex = new RegExp('\\b(' + wordsToRemove.join('|') + ')\\b', 'gi');
7
- const formattedIngrName = ingr
8
- .trim()
9
- .replace(/\s{2,}/g, ' ')
10
- .replace(/,/g, '')
11
- .replace(/^(fluid )/, '')
12
- .replace(/^(fl )/, '')
13
- .replace(/^(oz )/, '')
14
- .replace(regex, '')
15
- .trim();
16
- return { formattedIngrName, comment };
17
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"editIngredientString.js","sourceRoot":"","sources":["../../src/funcs/editIngredientString.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,OAAe,EAAE,EAAE;IACtD,sDAAsD;IACtD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EAAE,iBAAiB,CAAC,CAAA;KACzE;IAAC,OAAO,KAAK,EAAE;QACd,OAAO;YACL,KAAK,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE;YACjC,cAAc,EAAE,IAAI;YACpB,gBAAgB,EAAE,iBAAiB,IAAI,IAAI;SAC5C,CAAA;KACF;IACD,IAAI,aAAa,IAAI,QAAQ,EAAE;QAC7B,MAAM,EACJ,eAAe,EACf,IAAI,EACJ,YAAY,EACZ,IAAI,EACJ,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,EAAE,EACF,GAAG,eAAe,EACnB,GAAG,QAAQ,CAAA;QAEZ,MAAM,UAAU,GAAG,cAAc,CAC/B,UAAU,CAAC,QAAQ,EACnB,UAAU,CAAC,IAAI,EACf,eAAe,CAChB,CAAA;QAED,MAAM,SAAS,GAAG,mDAAmD,eAAe,CAAC,KAAK,EAAE,CAAA;QAC5F,MAAM,eAAe,GAAmB;YACtC,GAAG,eAAe;YAClB,SAAS;YACT,kBAAkB,EAAE,UAAU;SAC/B,CAAA;QAED,OAAO;YACL,cAAc,EAAE,eAAe;YAC/B,gBAAgB,EAAE,iBAAiB;SACpC,CAAA;KACF;SAAM;QACL,OAAO;YACL,KAAK,EAAE;gBACL,OAAO,EACL,sHAAsH;aACzH;YACD,cAAc,EAAE,IAAI;YACpB,gBAAgB,EAAE,iBAAiB;SACpC,CAAA;KACF;AACH,CAAC,CAAA;AAED,eAAe,gBAAgB,CAAA"}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,6BAA6B,CAAA;AAO1D,OAAO,EACL,gBAAgB,GAIjB,CAAA"}