Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ingredient-math

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ingredient-math - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

45

dist/index.js

@@ -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",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc