parse-ingredient
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -74,11 +74,15 @@ 'use strict'; | ||
} // Now check the description for a `quantity2` at the beginning. | ||
// First we look for a dash to indicate a range, then process the next seven | ||
// characters just like we did for `quantity`. | ||
// First we look for a dash, emdash, endash, or the word "to" to indicate | ||
// a range, then process the next seven characters just like we did for | ||
// `quantity`. | ||
var firstChar = oIng.description.substring(0, 1); | ||
var q2re = /^(-|–|—|to )/i; | ||
var q2reMatch = q2re.exec(oIng.description); | ||
if (firstChar === '-' || firstChar === "\u2013" || firstChar === "\u2014") { | ||
var _nqResultFirstChar = numericQuantity(oIng.description.substring(1).trim().substring(0, 1)); | ||
if (q2reMatch) { | ||
var q2reMatchLen = q2reMatch[1].length; | ||
var _nqResultFirstChar = numericQuantity(oIng.description.substring(q2reMatchLen).trim().substring(0, 1)); | ||
if (!isNaN(_nqResultFirstChar)) { | ||
@@ -89,3 +93,3 @@ var _lenNum = 6; | ||
while (_lenNum > 0 && isNaN(_nqResult)) { | ||
_nqResult = numericQuantity(oIng.description.substring(1, _lenNum)); | ||
_nqResult = numericQuantity(oIng.description.substring(q2reMatchLen, _lenNum)); | ||
@@ -92,0 +96,0 @@ if (!isNaN(_nqResult)) { |
@@ -1,2 +0,2 @@ | ||
"use strict";var t,i=(t=require("numeric-quantity"))&&"object"==typeof t&&"default"in t?t.default:t,s=["cup","cups","c","c.","C","teaspoon","teaspoons","tsp","tsp.","t","tablespoon","tablespoons","tbsp","tbsp.","T","ounce","ounces","oz","oz.","pint","pints","pt","pt.","pound","pounds","lb","lb.","lbs","lbs.","gram","grams","g","g.","kilogram","kilograms","kg","kg.","stick","sticks","inch","inches","in","in.","foot","feet","ft","ft.","quart","quarts","qt","qt.","liter","liters","l"];module.exports=function(t){return function(t){for(var i=-1,s=t.length,r=0,n=[];++i<s;){var e=t[i];e&&(n[r++]=e)}return n}(t.replace(/\n{2,}/g,"\n").split("\n").map((function(t){return t.trim()}))).map((function(t){var r={quantity:null,quantity2:null,unitOfMeasure:null,description:"",isGroupHeader:!1},n=i(t.substring(0,1));if(isNaN(n))r.description=t,(/:$/.test(r.description)||/^For /i.test(r.description))&&(r.isGroupHeader=!0);else for(var e=6,o=NaN;e>0&&isNaN(o);)(o=i(t.substring(0,e).trim()))>-1&&(r.quantity=o,r.description=t.substring(e).trim()),e--;var u=r.description.substring(0,1);if("-"===u||"–"===u||"—"===u){var a=i(r.description.substring(1).trim().substring(0,1));if(!isNaN(a))for(var p=6,c=NaN;p>0&&isNaN(c);)c=i(r.description.substring(1,p)),isNaN(c)||(r.quantity2=c,r.description=r.description.substring(p).trim()),p--}var l=r.description.indexOf(" "),d=r.description.substring(0,l);return s.indexOf(d)>=0&&(r.unitOfMeasure=d,r.description=r.description.substring(l+1)),r}))}; | ||
"use strict";var t,i=(t=require("numeric-quantity"))&&"object"==typeof t&&"default"in t?t.default:t,s=["cup","cups","c","c.","C","teaspoon","teaspoons","tsp","tsp.","t","tablespoon","tablespoons","tbsp","tbsp.","T","ounce","ounces","oz","oz.","pint","pints","pt","pt.","pound","pounds","lb","lb.","lbs","lbs.","gram","grams","g","g.","kilogram","kilograms","kg","kg.","stick","sticks","inch","inches","in","in.","foot","feet","ft","ft.","quart","quarts","qt","qt.","liter","liters","l"];module.exports=function(t){return function(t){for(var i=-1,s=t.length,r=0,n=[];++i<s;){var e=t[i];e&&(n[r++]=e)}return n}(t.replace(/\n{2,}/g,"\n").split("\n").map((function(t){return t.trim()}))).map((function(t){var r={quantity:null,quantity2:null,unitOfMeasure:null,description:"",isGroupHeader:!1},n=i(t.substring(0,1));if(isNaN(n))r.description=t,(/:$/.test(r.description)||/^For /i.test(r.description))&&(r.isGroupHeader=!0);else for(var e=6,o=NaN;e>0&&isNaN(o);)(o=i(t.substring(0,e).trim()))>-1&&(r.quantity=o,r.description=t.substring(e).trim()),e--;var u=/^(-|–|—|to )/i.exec(r.description);if(u){var a=u[1].length,p=i(r.description.substring(a).trim().substring(0,1));if(!isNaN(p))for(var c=6,l=NaN;c>0&&isNaN(l);)l=i(r.description.substring(a,c)),isNaN(l)||(r.quantity2=l,r.description=r.description.substring(c).trim()),c--}var d=r.description.indexOf(" "),f=r.description.substring(0,d);return s.indexOf(f)>=0&&(r.unitOfMeasure=f,r.description=r.description.substring(d+1)),r}))}; | ||
//# sourceMappingURL=parse-ingredient.cjs.production.min.js.map |
@@ -70,11 +70,15 @@ import numericQuantity from 'numeric-quantity'; | ||
} // Now check the description for a `quantity2` at the beginning. | ||
// First we look for a dash to indicate a range, then process the next seven | ||
// characters just like we did for `quantity`. | ||
// First we look for a dash, emdash, endash, or the word "to" to indicate | ||
// a range, then process the next seven characters just like we did for | ||
// `quantity`. | ||
var firstChar = oIng.description.substring(0, 1); | ||
var q2re = /^(-|–|—|to )/i; | ||
var q2reMatch = q2re.exec(oIng.description); | ||
if (firstChar === '-' || firstChar === "\u2013" || firstChar === "\u2014") { | ||
var _nqResultFirstChar = numericQuantity(oIng.description.substring(1).trim().substring(0, 1)); | ||
if (q2reMatch) { | ||
var q2reMatchLen = q2reMatch[1].length; | ||
var _nqResultFirstChar = numericQuantity(oIng.description.substring(q2reMatchLen).trim().substring(0, 1)); | ||
if (!isNaN(_nqResultFirstChar)) { | ||
@@ -85,3 +89,3 @@ var _lenNum = 6; | ||
while (_lenNum > 0 && isNaN(_nqResult)) { | ||
_nqResult = numericQuantity(oIng.description.substring(1, _lenNum)); | ||
_nqResult = numericQuantity(oIng.description.substring(q2reMatchLen, _lenNum)); | ||
@@ -88,0 +92,0 @@ if (!isNaN(_nqResult)) { |
@@ -77,11 +77,15 @@ System.register('parseIngredient', ['numeric-quantity'], function (exports) { | ||
} // Now check the description for a `quantity2` at the beginning. | ||
// First we look for a dash to indicate a range, then process the next seven | ||
// characters just like we did for `quantity`. | ||
// First we look for a dash, emdash, endash, or the word "to" to indicate | ||
// a range, then process the next seven characters just like we did for | ||
// `quantity`. | ||
var firstChar = oIng.description.substring(0, 1); | ||
var q2re = /^(-|–|—|to )/i; | ||
var q2reMatch = q2re.exec(oIng.description); | ||
if (firstChar === '-' || firstChar === "\u2013" || firstChar === "\u2014") { | ||
var _nqResultFirstChar = numericQuantity(oIng.description.substring(1).trim().substring(0, 1)); | ||
if (q2reMatch) { | ||
var q2reMatchLen = q2reMatch[1].length; | ||
var _nqResultFirstChar = numericQuantity(oIng.description.substring(q2reMatchLen).trim().substring(0, 1)); | ||
if (!isNaN(_nqResultFirstChar)) { | ||
@@ -92,3 +96,3 @@ var _lenNum = 6; | ||
while (_lenNum > 0 && isNaN(_nqResult)) { | ||
_nqResult = numericQuantity(oIng.description.substring(1, _lenNum)); | ||
_nqResult = numericQuantity(oIng.description.substring(q2reMatchLen, _lenNum)); | ||
@@ -95,0 +99,0 @@ if (!isNaN(_nqResult)) { |
@@ -1,2 +0,2 @@ | ||
System.register("parseIngredient",["numeric-quantity"],(function(t){"use strict";var i;return{setters:[function(t){i=t.default}],execute:function(){var s=["cup","cups","c","c.","C","teaspoon","teaspoons","tsp","tsp.","t","tablespoon","tablespoons","tbsp","tbsp.","T","ounce","ounces","oz","oz.","pint","pints","pt","pt.","pound","pounds","lb","lb.","lbs","lbs.","gram","grams","g","g.","kilogram","kilograms","kg","kg.","stick","sticks","inch","inches","in","in.","foot","feet","ft","ft.","quart","quarts","qt","qt.","liter","liters","l"];t("default",(function(t){return function(t){for(var i=-1,s=t.length,n=0,r=[];++i<s;){var e=t[i];e&&(r[n++]=e)}return r}(t.replace(/\n{2,}/g,"\n").split("\n").map((function(t){return t.trim()}))).map((function(t){var n={quantity:null,quantity2:null,unitOfMeasure:null,description:"",isGroupHeader:!1},r=i(t.substring(0,1));if(isNaN(r))n.description=t,(/:$/.test(n.description)||/^For /i.test(n.description))&&(n.isGroupHeader=!0);else for(var e=6,u=NaN;e>0&&isNaN(u);)(u=i(t.substring(0,e).trim()))>-1&&(n.quantity=u,n.description=t.substring(e).trim()),e--;var o=n.description.substring(0,1);if("-"===o||"–"===o||"—"===o){var a=i(n.description.substring(1).trim().substring(0,1));if(!isNaN(a))for(var p=6,c=NaN;p>0&&isNaN(c);)c=i(n.description.substring(1,p)),isNaN(c)||(n.quantity2=c,n.description=n.description.substring(p).trim()),p--}var d=n.description.indexOf(" "),f=n.description.substring(0,d);return s.indexOf(f)>=0&&(n.unitOfMeasure=f,n.description=n.description.substring(d+1)),n}))}))}}})); | ||
System.register("parseIngredient",["numeric-quantity"],(function(t){"use strict";var i;return{setters:[function(t){i=t.default}],execute:function(){var n=["cup","cups","c","c.","C","teaspoon","teaspoons","tsp","tsp.","t","tablespoon","tablespoons","tbsp","tbsp.","T","ounce","ounces","oz","oz.","pint","pints","pt","pt.","pound","pounds","lb","lb.","lbs","lbs.","gram","grams","g","g.","kilogram","kilograms","kg","kg.","stick","sticks","inch","inches","in","in.","foot","feet","ft","ft.","quart","quarts","qt","qt.","liter","liters","l"];t("default",(function(t){return function(t){for(var i=-1,n=t.length,s=0,r=[];++i<n;){var e=t[i];e&&(r[s++]=e)}return r}(t.replace(/\n{2,}/g,"\n").split("\n").map((function(t){return t.trim()}))).map((function(t){var s={quantity:null,quantity2:null,unitOfMeasure:null,description:"",isGroupHeader:!1},r=i(t.substring(0,1));if(isNaN(r))s.description=t,(/:$/.test(s.description)||/^For /i.test(s.description))&&(s.isGroupHeader=!0);else for(var e=6,u=NaN;e>0&&isNaN(u);)(u=i(t.substring(0,e).trim()))>-1&&(s.quantity=u,s.description=t.substring(e).trim()),e--;var o=/^(-|–|—|to )/i.exec(s.description);if(o){var a=o[1].length,p=i(s.description.substring(a).trim().substring(0,1));if(!isNaN(p))for(var c=6,l=NaN;c>0&&isNaN(l);)l=i(s.description.substring(a,c)),isNaN(l)||(s.quantity2=l,s.description=s.description.substring(c).trim()),c--}var d=s.description.indexOf(" "),f=s.description.substring(0,d);return n.indexOf(f)>=0&&(s.unitOfMeasure=f,s.description=s.description.substring(d+1)),s}))}))}}})); | ||
//# sourceMappingURL=parse-ingredient.system.production.min.js.map |
@@ -76,11 +76,15 @@ (function (global, factory) { | ||
} // Now check the description for a `quantity2` at the beginning. | ||
// First we look for a dash to indicate a range, then process the next seven | ||
// characters just like we did for `quantity`. | ||
// First we look for a dash, emdash, endash, or the word "to" to indicate | ||
// a range, then process the next seven characters just like we did for | ||
// `quantity`. | ||
var firstChar = oIng.description.substring(0, 1); | ||
var q2re = /^(-|–|—|to )/i; | ||
var q2reMatch = q2re.exec(oIng.description); | ||
if (firstChar === '-' || firstChar === "\u2013" || firstChar === "\u2014") { | ||
var _nqResultFirstChar = numericQuantity(oIng.description.substring(1).trim().substring(0, 1)); | ||
if (q2reMatch) { | ||
var q2reMatchLen = q2reMatch[1].length; | ||
var _nqResultFirstChar = numericQuantity(oIng.description.substring(q2reMatchLen).trim().substring(0, 1)); | ||
if (!isNaN(_nqResultFirstChar)) { | ||
@@ -91,3 +95,3 @@ var _lenNum = 6; | ||
while (_lenNum > 0 && isNaN(_nqResult)) { | ||
_nqResult = numericQuantity(oIng.description.substring(1, _lenNum)); | ||
_nqResult = numericQuantity(oIng.description.substring(q2reMatchLen, _lenNum)); | ||
@@ -94,0 +98,0 @@ if (!isNaN(_nqResult)) { |
@@ -1,2 +0,2 @@ | ||
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i(require("numeric-quantity")):"function"==typeof define&&define.amd?define(["numeric-quantity"],i):(t=t||self).parseIngredient=i(t.numericQuantity)}(this,(function(t){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var i=["cup","cups","c","c.","C","teaspoon","teaspoons","tsp","tsp.","t","tablespoon","tablespoons","tbsp","tbsp.","T","ounce","ounces","oz","oz.","pint","pints","pt","pt.","pound","pounds","lb","lb.","lbs","lbs.","gram","grams","g","g.","kilogram","kilograms","kg","kg.","stick","sticks","inch","inches","in","in.","foot","feet","ft","ft.","quart","quarts","qt","qt.","liter","liters","l"];return function(n){return function(t){for(var i=-1,n=t.length,r=0,s=[];++i<n;){var e=t[i];e&&(s[r++]=e)}return s}(n.replace(/\n{2,}/g,"\n").split("\n").map((function(t){return t.trim()}))).map((function(n){var r={quantity:null,quantity2:null,unitOfMeasure:null,description:"",isGroupHeader:!1},s=t(n.substring(0,1));if(isNaN(s))r.description=n,(/:$/.test(r.description)||/^For /i.test(r.description))&&(r.isGroupHeader=!0);else for(var e=6,o=NaN;e>0&&isNaN(o);)(o=t(n.substring(0,e).trim()))>-1&&(r.quantity=o,r.description=n.substring(e).trim()),e--;var u=r.description.substring(0,1);if("-"===u||"–"===u||"—"===u){var a=t(r.description.substring(1).trim().substring(0,1));if(!isNaN(a))for(var p=6,c=NaN;p>0&&isNaN(c);)c=t(r.description.substring(1,p)),isNaN(c)||(r.quantity2=c,r.description=r.description.substring(p).trim()),p--}var d=r.description.indexOf(" "),f=r.description.substring(0,d);return i.indexOf(f)>=0&&(r.unitOfMeasure=f,r.description=r.description.substring(d+1)),r}))}})); | ||
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i(require("numeric-quantity")):"function"==typeof define&&define.amd?define(["numeric-quantity"],i):(t=t||self).parseIngredient=i(t.numericQuantity)}(this,(function(t){"use strict";t=t&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t;var i=["cup","cups","c","c.","C","teaspoon","teaspoons","tsp","tsp.","t","tablespoon","tablespoons","tbsp","tbsp.","T","ounce","ounces","oz","oz.","pint","pints","pt","pt.","pound","pounds","lb","lb.","lbs","lbs.","gram","grams","g","g.","kilogram","kilograms","kg","kg.","stick","sticks","inch","inches","in","in.","foot","feet","ft","ft.","quart","quarts","qt","qt.","liter","liters","l"];return function(n){return function(t){for(var i=-1,n=t.length,e=0,r=[];++i<n;){var s=t[i];s&&(r[e++]=s)}return r}(n.replace(/\n{2,}/g,"\n").split("\n").map((function(t){return t.trim()}))).map((function(n){var e={quantity:null,quantity2:null,unitOfMeasure:null,description:"",isGroupHeader:!1},r=t(n.substring(0,1));if(isNaN(r))e.description=n,(/:$/.test(e.description)||/^For /i.test(e.description))&&(e.isGroupHeader=!0);else for(var s=6,o=NaN;s>0&&isNaN(o);)(o=t(n.substring(0,s).trim()))>-1&&(e.quantity=o,e.description=n.substring(s).trim()),s--;var u=/^(-|–|—|to )/i.exec(e.description);if(u){var a=u[1].length,p=t(e.description.substring(a).trim().substring(0,1));if(!isNaN(p))for(var c=6,d=NaN;c>0&&isNaN(d);)d=t(e.description.substring(a,c)),isNaN(d)||(e.quantity2=d,e.description=e.description.substring(c).trim()),c--}var f=e.description.indexOf(" "),l=e.description.substring(0,f);return i.indexOf(l)>=0&&(e.unitOfMeasure=l,e.description=e.description.substring(f+1)),e}))}})); | ||
//# sourceMappingURL=parse-ingredient.umd.production.min.js.map |
{ | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"license": "MIT", | ||
@@ -35,3 +35,4 @@ "description": "Recipe ingredient parser with support for mixed numbers and vulgar fractions", | ||
"publish:npm": "np", | ||
"publish:demo": "node gh-pages.publish.js" | ||
"publish:demo": "node gh-pages.publish.js", | ||
"generate-changelog": "npx github-changes -o jakeboone02 -r parse-ingredient -a --use-commit-body --date-format=\"(YYYY-MM-DD)\"" | ||
}, | ||
@@ -38,0 +39,0 @@ "prettier": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
85210
20
430