@recipe-book/core 0.0.1 → 0.0.3
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/{chunk-2WUP3JQY.mjs → chunk-3FFMHRB7.mjs} +3 -2
- package/dist/{chunk-IEYO4T4T.mjs → chunk-4EHNJLGI.mjs} +9 -8
- package/dist/chunk-4IA5EEKI.mjs +81 -0
- package/dist/chunk-4TATADPT.mjs +51 -0
- package/dist/chunk-6GI5KLI4.mjs +22 -0
- package/dist/chunk-6YYQ4RYZ.mjs +26 -0
- package/dist/chunk-7BBUDI2L.mjs +0 -0
- package/dist/chunk-7KEMNCV7.mjs +26 -0
- package/dist/chunk-7MMJZZ7Z.mjs +75 -0
- package/dist/chunk-BES4V7DM.mjs +26 -0
- package/dist/{chunk-OBJ5JUVG.mjs → chunk-BRDXRIAH.mjs} +5 -4
- package/dist/chunk-CFR2ZBPB.mjs +77 -0
- package/dist/chunk-DYMNVFL2.mjs +78 -0
- package/dist/{chunk-NJQRYZC2.mjs → chunk-F6AQKXJU.mjs} +7 -4
- package/dist/chunk-FW4M2R43.mjs +51 -0
- package/dist/chunk-GCCEDUST.mjs +75 -0
- package/dist/chunk-GE7KBYZR.mjs +26 -0
- package/dist/chunk-GN7ZDGYC.mjs +51 -0
- package/dist/chunk-GOO2SCQX.mjs +75 -0
- package/dist/chunk-HAVKBQLH.mjs +51 -0
- package/dist/chunk-HCBIPANU.mjs +50 -0
- package/dist/chunk-IEBAGBS7.mjs +51 -0
- package/dist/chunk-IQ6WN2V4.mjs +75 -0
- package/dist/chunk-JB4Z2FR7.mjs +77 -0
- package/dist/chunk-JMTQOTBM.mjs +75 -0
- package/dist/{chunk-JPGZ2MYF.mjs → chunk-JRO6JUES.mjs} +9 -6
- package/dist/chunk-KH3SRXET.mjs +52 -0
- package/dist/chunk-KNZMCAQZ.mjs +51 -0
- package/dist/chunk-LEBGCVCJ.mjs +75 -0
- package/dist/chunk-MAHWFCIL.mjs +51 -0
- package/dist/chunk-MPH76SLC.mjs +51 -0
- package/dist/chunk-MQGMFBJQ.mjs +26 -0
- package/dist/chunk-NMIVG7T4.mjs +6 -0
- package/dist/chunk-Q3TT3AZ4.mjs +26 -0
- package/dist/chunk-QY5HJQIL.mjs +51 -0
- package/dist/chunk-RCPLSNKM.mjs +1 -0
- package/dist/chunk-UQ3EUYFR.mjs +1 -0
- package/dist/chunk-WSW6FMUL.mjs +51 -0
- package/dist/chunk-WU55SBIV.mjs +75 -0
- package/dist/chunk-XINK45P3.mjs +51 -0
- package/dist/chunk-XNOHIWI3.mjs +1 -0
- package/dist/chunk-YHBXEVUX.mjs +51 -0
- package/dist/chunk-YSZSCEI7.mjs +75 -0
- package/dist/const/conversion.d.mts +2 -2
- package/dist/const/conversion.d.ts +2 -2
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/lib/ingredient.d.mts +3 -2
- package/dist/lib/ingredient.d.ts +3 -2
- package/dist/lib/ingredient.js +1 -1
- package/dist/lib/ingredient.mjs +1 -1
- package/dist/lib/recipe.d.mts +4 -2
- package/dist/lib/recipe.d.ts +4 -2
- package/dist/lib/recipe.js +1 -1
- package/dist/lib/recipe.mjs +1 -1
- package/dist/lib/unit.d.mts +5 -4
- package/dist/lib/unit.d.ts +5 -4
- package/dist/lib/unit.js +1 -1
- package/dist/lib/unit.mjs +1 -1
- package/dist/types.d.mts +17 -12
- package/dist/types.d.ts +17 -12
- package/dist/types.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-4AN32V3Z.mjs +0 -1
- package/dist/chunk-5ZCZ6LQB.mjs +0 -1
- package/dist/chunk-BOG6H6FE.mjs +0 -1
- package/dist/chunk-CEPTOQUR.mjs +0 -1
- package/dist/chunk-EKLUF5ED.mjs +0 -1
- package/dist/chunk-LLHRB3T7.mjs +0 -1
- package/dist/chunk-MUILH2IA.mjs +0 -1
- package/dist/chunk-YHBHNGQX.mjs +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { RecipeUtils } from './lib/recipe.js';
|
|
2
2
|
export { UnitUtils } from './lib/unit.js';
|
|
3
3
|
export { IngredientUtils } from './lib/ingredient.js';
|
|
4
|
-
export { GlobalRecipeConfig, Ingredient, IngredientAmount, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName } from './types.js';
|
|
4
|
+
export { ConversionTables, GlobalRecipeConfig, Ingredient, IngredientAmount, Instruction, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName } from './types.js';
|
|
5
5
|
import './const/unit.js';
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var m=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var E=(o,e)=>{for(var t in e)m(o,t,{get:e[t],enumerable:!0})},w=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of h(e))!R.call(o,i)&&i!==t&&m(o,i,{get:()=>e[i],enumerable:!(n=d(e,i))||n.enumerable});return o};var I=o=>w(m({},"__esModule",{value:!0}),o);var C={};E(C,{IngredientUtils:()=>T,RecipeUtils:()=>g,UnitUtils:()=>s});module.exports=I(C);function u(o,e,t){if(!e(o))throw new Error(t)}function a(o,e,t){e(o)||console.warn(t)}var p=class{scopedMessageFactory(e){return t=>`${e.name}: ${t}`}validateConfig(e){if(!!0)return;let t=this.scopedMessageFactory(e);a(e.instructions,n=>n.length>0,t("Recipe has no instructions")),a(e.serves,n=>n===void 0||n>0,t("Recipe serves less than 1 person")),a(e.ingredients,n=>n.length>0,t("Recipe has no ingredients"))}determineMeasurementSystem(e){let{ingredients:t}=e,n=t.some(r=>r.amount.unit==="g"),i=t.some(r=>r.amount.unit==="oz"||r.amount.unit==="fl oz"||r.amount.unit==="lb"||r.amount.unit==="cup");if(!(n&&i)){if(n)return"metric";if(i)return"us-customary"}}create(e){return this.validateConfig(e),{name:e.name,ingredients:e.ingredients,thumbnail:e.thumbnail,serves:e.serves??1,instructions:e.instructions??[],measurements:e.measurements??this.determineMeasurementSystem(e)}}},g=new p;var y={g:{g:1,kg:1e3,oz:28.3495,lb:453.592},kg:{g:.001,kg:1,oz:.0283495,lb:.453592},oz:{g:.035274,kg:35.274,oz:1,lb:16},lb:{g:.00220462,kg:2.20462,oz:.0625,lb:1}},f={L:{L:1,gal:3.78541,mL:.001,cup:.0625,tsp:.202884,tbsp:.067628},gal:{L:.264172,gal:1,mL:264172e-9,cup:.016,tsp:.0515037,tbsp:.0171679},mL:{L:1e3,gal:3785.41,mL:1,cup:.00422675,tsp:.033814,tbsp:.00422675},cup:{L:4.22675,gal:16,mL:236.588,cup:1,tsp:3.2,tbsp:1.06667},tsp:{L:4.92892,gal:18.6184,mL:4.92892,cup:.3125,tsp:1,tbsp:.333333},tbsp:{L:14.7868,gal:56,mL:14.7868,cup:.9375,tsp:3,tbsp:1}};var N=[{key:!0,name:"gram",abbreviation:"g",value:1,type:"weight"},{name:"kilogram",abbreviation:"kg",value:1e3,type:"weight"},{name:"ounce",abbreviation:"oz",value:28.3495,type:"weight"},{name:"pound",abbreviation:"lb",value:453.592,type:"weight"}],x=[{key:!0,name:"liter",abbreviation:"L",value:1,type:"volume"},{name:"gallon",abbreviation:"gal",value:3.78541,type:"volume"},{name:"milliliter",abbreviation:"mL",value:.001,type:"volume"},{name:"cup",abbreviation:"cup",value:.0625,type:"volume"},{name:"teaspoon",abbreviation:"tsp",value:.0208333,type:"volume"},{name:"tablespoon",abbreviation:"tbsp",value:.0625,type:"volume"},{name:"fluid ounce",abbreviation:"fl oz",value:.125,type:"volume"}],L=[...N,...x];var l=class{getUnit(e){let t=L.find(n=>n.abbreviation===e||n.name===e);return u(t,n=>!!n,`No unit found for key: ${e}`),t}getConversionRatio(e,t){let{type:n,abbreviation:i}=this.getUnit(e),b=(n==="volume"?f:y)[i],v=t==="metric"?n==="volume"?"L":"g":t;return u(b,U=>!!U[v],`No conversion table available for unit ${e} to ${t}`),b[v]}convert(e,t,n){if(t===n)return e;let i=this.getConversionRatio(t,n),r=e*i;return Math.round(r*100)/100}},s=new l;var c=class{convert(e,t){let n=s.convert(e.amount.value,e.amount.unit,t);return{...e,amount:{value:n,unit:t}}}},T=new c;0&&(module.exports={IngredientUtils,RecipeUtils,UnitUtils});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-WBQAMGXK.mjs";import{a as i}from"./chunk-
|
|
1
|
+
import"./chunk-WBQAMGXK.mjs";import{a as i}from"./chunk-RCPLSNKM.mjs";import{a as t}from"./chunk-XNOHIWI3.mjs";import"./chunk-KXFUCO3R.mjs";import"./chunk-22RBQQWH.mjs";import{a as r}from"./chunk-UQ3EUYFR.mjs";import"./chunk-C45UD45A.mjs";import"./chunk-3CSP4UZG.mjs";export{i as IngredientUtils,r as RecipeUtils,t as UnitUtils};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Ingredient, UnitKey } from '../types.mjs';
|
|
2
2
|
import '../const/unit.mjs';
|
|
3
3
|
|
|
4
|
-
declare
|
|
5
|
-
convert
|
|
4
|
+
declare class IngredientUtilsImpl {
|
|
5
|
+
convert(ingredient: Ingredient, to: UnitKey): Ingredient;
|
|
6
6
|
}
|
|
7
|
+
declare const IngredientUtils: IngredientUtilsImpl;
|
|
7
8
|
|
|
8
9
|
export { IngredientUtils };
|
package/dist/lib/ingredient.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Ingredient, UnitKey } from '../types.js';
|
|
2
2
|
import '../const/unit.js';
|
|
3
3
|
|
|
4
|
-
declare
|
|
5
|
-
convert
|
|
4
|
+
declare class IngredientUtilsImpl {
|
|
5
|
+
convert(ingredient: Ingredient, to: UnitKey): Ingredient;
|
|
6
6
|
}
|
|
7
|
+
declare const IngredientUtils: IngredientUtilsImpl;
|
|
7
8
|
|
|
8
9
|
export { IngredientUtils };
|
package/dist/lib/ingredient.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var i=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var U=Object.prototype.hasOwnProperty;var f=(n,e)=>{for(var t in e)i(n,t,{get:e[t],enumerable:!0})},E=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of T(e))!U.call(n,a)&&a!==t&&i(n,a,{get:()=>e[a],enumerable:!(o=L(e,a))||o.enumerable});return n};var N=n=>E(i({},"__esModule",{value:!0}),n);var h={};f(h,{IngredientUtils:()=>I});module.exports=N(h);var v={g:{g:1,kg:1e3,oz:28.3495,lb:453.592},kg:{g:.001,kg:1,oz:.0283495,lb:.453592},oz:{g:.035274,kg:35.274,oz:1,lb:16},lb:{g:.00220462,kg:2.20462,oz:.0625,lb:1}},m={L:{L:1,gal:3.78541,mL:.001,cup:.0625,tsp:.202884,tbsp:.067628},gal:{L:.264172,gal:1,mL:264172e-9,cup:.016,tsp:.0515037,tbsp:.0171679},mL:{L:1e3,gal:3785.41,mL:1,cup:.00422675,tsp:.033814,tbsp:.00422675},cup:{L:4.22675,gal:16,mL:236.588,cup:1,tsp:3.2,tbsp:1.06667},tsp:{L:4.92892,gal:18.6184,mL:4.92892,cup:.3125,tsp:1,tbsp:.333333},tbsp:{L:14.7868,gal:56,mL:14.7868,cup:.9375,tsp:3,tbsp:1}};var k=[{key:!0,name:"gram",abbreviation:"g",value:1,type:"weight"},{name:"kilogram",abbreviation:"kg",value:1e3,type:"weight"},{name:"ounce",abbreviation:"oz",value:28.3495,type:"weight"},{name:"pound",abbreviation:"lb",value:453.592,type:"weight"}],w=[{key:!0,name:"liter",abbreviation:"L",value:1,type:"volume"},{name:"gallon",abbreviation:"gal",value:3.78541,type:"volume"},{name:"milliliter",abbreviation:"mL",value:.001,type:"volume"},{name:"cup",abbreviation:"cup",value:.0625,type:"volume"},{name:"teaspoon",abbreviation:"tsp",value:.0208333,type:"volume"},{name:"tablespoon",abbreviation:"tbsp",value:.0625,type:"volume"},{name:"fluid ounce",abbreviation:"fl oz",value:.125,type:"volume"}],c=[...k,...w];function r(n,e,t){if(!e(n))throw new Error(t)}var s=class{getUnit(e){let t=c.find(o=>o.abbreviation===e||o.name===e);return r(t,o=>!!o,`No unit found for key: ${e}`),t}getConversionRatio(e,t){let{type:o,abbreviation:a}=this.getUnit(e),p=(o==="volume"?m:v)[a],u=t==="metric"?o==="volume"?"L":"g":t;return r(p,y=>!!y[u],`No conversion table available for unit ${e} to ${t}`),p[u]}convert(e,t,o){if(t===o)return e;let a=this.getConversionRatio(t,o),b=e*a;return Math.round(b*100)/100}},g=new s;var l=class{convert(e,t){let o=g.convert(e.amount.value,e.amount.unit,t);return{...e,amount:{value:o,unit:t}}}},I=new l;0&&(module.exports={IngredientUtils});
|
package/dist/lib/ingredient.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-RCPLSNKM.mjs";import"../chunk-XNOHIWI3.mjs";import"../chunk-KXFUCO3R.mjs";import"../chunk-22RBQQWH.mjs";import"../chunk-C45UD45A.mjs";export{a as IngredientUtils};
|
package/dist/lib/recipe.d.mts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { RecipeConfig, Recipe } from '../types.mjs';
|
|
2
2
|
import '../const/unit.mjs';
|
|
3
3
|
|
|
4
|
-
declare
|
|
4
|
+
declare class RecipeUtilsImpl {
|
|
5
5
|
private scopedMessageFactory;
|
|
6
6
|
private validateConfig;
|
|
7
|
-
|
|
7
|
+
private determineMeasurementSystem;
|
|
8
|
+
create(config: RecipeConfig): Recipe;
|
|
8
9
|
}
|
|
10
|
+
declare const RecipeUtils: RecipeUtilsImpl;
|
|
9
11
|
|
|
10
12
|
export { RecipeUtils };
|
package/dist/lib/recipe.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { RecipeConfig, Recipe } from '../types.js';
|
|
2
2
|
import '../const/unit.js';
|
|
3
3
|
|
|
4
|
-
declare
|
|
4
|
+
declare class RecipeUtilsImpl {
|
|
5
5
|
private scopedMessageFactory;
|
|
6
6
|
private validateConfig;
|
|
7
|
-
|
|
7
|
+
private determineMeasurementSystem;
|
|
8
|
+
create(config: RecipeConfig): Recipe;
|
|
8
9
|
}
|
|
10
|
+
declare const RecipeUtils: RecipeUtilsImpl;
|
|
9
11
|
|
|
10
12
|
export { RecipeUtils };
|
package/dist/lib/recipe.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var l=(s,e)=>{for(var t in e)o(s,t,{get:e[t],enumerable:!0})},d=(s,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of p(e))!c.call(s,r)&&r!==t&&o(s,r,{get:()=>e[r],enumerable:!(n=m(e,r))||n.enumerable});return s};var h=s=>d(o({},"__esModule",{value:!0}),s);var v={};l(v,{RecipeUtils:()=>f});module.exports=h(v);function a(s,e,t){e(s)||console.warn(t)}var u=class{scopedMessageFactory(e){return t=>`${e.name}: ${t}`}validateConfig(e){if(!!0)return;let t=this.scopedMessageFactory(e);a(e.instructions,n=>n.length>0,t("Recipe has no instructions")),a(e.serves,n=>n===void 0||n>0,t("Recipe serves less than 1 person")),a(e.ingredients,n=>n.length>0,t("Recipe has no ingredients"))}determineMeasurementSystem(e){let{ingredients:t}=e,n=t.some(i=>i.amount.unit==="g"),r=t.some(i=>i.amount.unit==="oz"||i.amount.unit==="fl oz"||i.amount.unit==="lb"||i.amount.unit==="cup");if(!(n&&r)){if(n)return"metric";if(r)return"us-customary"}}create(e){return this.validateConfig(e),{name:e.name,ingredients:e.ingredients,thumbnail:e.thumbnail,serves:e.serves??1,instructions:e.instructions??[],measurements:e.measurements??this.determineMeasurementSystem(e)}}},f=new u;0&&(module.exports={RecipeUtils});
|
package/dist/lib/recipe.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-UQ3EUYFR.mjs";import"../chunk-C45UD45A.mjs";import"../chunk-3CSP4UZG.mjs";export{a as RecipeUtils};
|
package/dist/lib/unit.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { UnitKey } from '../types.mjs';
|
|
2
2
|
import '../const/unit.mjs';
|
|
3
3
|
|
|
4
|
-
declare
|
|
5
|
-
private
|
|
6
|
-
private
|
|
4
|
+
declare class UnitUtilsImpl {
|
|
5
|
+
private getUnit;
|
|
6
|
+
private getConversionRatio;
|
|
7
7
|
/**
|
|
8
8
|
* Converts a number from one unit to another
|
|
9
9
|
*
|
|
@@ -12,7 +12,8 @@ declare abstract class UnitUtils {
|
|
|
12
12
|
* @param to - The unit to convert to
|
|
13
13
|
* @returns - The converted amount
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
convert(amount: number, from: UnitKey, to: UnitKey): number;
|
|
16
16
|
}
|
|
17
|
+
declare const UnitUtils: UnitUtilsImpl;
|
|
17
18
|
|
|
18
19
|
export { UnitUtils };
|
package/dist/lib/unit.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { UnitKey } from '../types.js';
|
|
2
2
|
import '../const/unit.js';
|
|
3
3
|
|
|
4
|
-
declare
|
|
5
|
-
private
|
|
6
|
-
private
|
|
4
|
+
declare class UnitUtilsImpl {
|
|
5
|
+
private getUnit;
|
|
6
|
+
private getConversionRatio;
|
|
7
7
|
/**
|
|
8
8
|
* Converts a number from one unit to another
|
|
9
9
|
*
|
|
@@ -12,7 +12,8 @@ declare abstract class UnitUtils {
|
|
|
12
12
|
* @param to - The unit to convert to
|
|
13
13
|
* @returns - The converted amount
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
convert(amount: number, from: UnitKey, to: UnitKey): number;
|
|
16
16
|
}
|
|
17
|
+
declare const UnitUtils: UnitUtilsImpl;
|
|
17
18
|
|
|
18
19
|
export { UnitUtils };
|
package/dist/lib/unit.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var i=Object.defineProperty;var
|
|
1
|
+
var i=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var y=(n,e)=>{for(var t in e)i(n,t,{get:e[t],enumerable:!0})},U=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of L(e))!T.call(n,a)&&a!==t&&i(n,a,{get:()=>e[a],enumerable:!(o=g(e,a))||o.enumerable});return n};var E=n=>U(i({},"__esModule",{value:!0}),n);var h={};y(h,{UnitUtils:()=>k});module.exports=E(h);var v={g:{g:1,kg:1e3,oz:28.3495,lb:453.592},kg:{g:.001,kg:1,oz:.0283495,lb:.453592},oz:{g:.035274,kg:35.274,oz:1,lb:16},lb:{g:.00220462,kg:2.20462,oz:.0625,lb:1}},u={L:{L:1,gal:3.78541,mL:.001,cup:.0625,tsp:.202884,tbsp:.067628},gal:{L:.264172,gal:1,mL:264172e-9,cup:.016,tsp:.0515037,tbsp:.0171679},mL:{L:1e3,gal:3785.41,mL:1,cup:.00422675,tsp:.033814,tbsp:.00422675},cup:{L:4.22675,gal:16,mL:236.588,cup:1,tsp:3.2,tbsp:1.06667},tsp:{L:4.92892,gal:18.6184,mL:4.92892,cup:.3125,tsp:1,tbsp:.333333},tbsp:{L:14.7868,gal:56,mL:14.7868,cup:.9375,tsp:3,tbsp:1}};var N=[{key:!0,name:"gram",abbreviation:"g",value:1,type:"weight"},{name:"kilogram",abbreviation:"kg",value:1e3,type:"weight"},{name:"ounce",abbreviation:"oz",value:28.3495,type:"weight"},{name:"pound",abbreviation:"lb",value:453.592,type:"weight"}],f=[{key:!0,name:"liter",abbreviation:"L",value:1,type:"volume"},{name:"gallon",abbreviation:"gal",value:3.78541,type:"volume"},{name:"milliliter",abbreviation:"mL",value:.001,type:"volume"},{name:"cup",abbreviation:"cup",value:.0625,type:"volume"},{name:"teaspoon",abbreviation:"tsp",value:.0208333,type:"volume"},{name:"tablespoon",abbreviation:"tbsp",value:.0625,type:"volume"},{name:"fluid ounce",abbreviation:"fl oz",value:.125,type:"volume"}],c=[...N,...f];function r(n,e,t){if(!e(n))throw new Error(t)}var b=class{getUnit(e){let t=c.find(o=>o.abbreviation===e||o.name===e);return r(t,o=>!!o,`No unit found for key: ${e}`),t}getConversionRatio(e,t){let{type:o,abbreviation:a}=this.getUnit(e),l=(o==="volume"?u:v)[a],p=t==="metric"?o==="volume"?"L":"g":t;return r(l,m=>!!m[p],`No conversion table available for unit ${e} to ${t}`),l[p]}convert(e,t,o){if(t===o)return e;let a=this.getConversionRatio(t,o),s=e*a;return Math.round(s*100)/100}},k=new b;0&&(module.exports={UnitUtils});
|
package/dist/lib/unit.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-XNOHIWI3.mjs";import"../chunk-KXFUCO3R.mjs";import"../chunk-22RBQQWH.mjs";import"../chunk-C45UD45A.mjs";export{a as UnitUtils};
|
package/dist/types.d.mts
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
import { UNITS } from './const/unit.mjs';
|
|
2
2
|
|
|
3
|
+
type ConversionTables = 'us-customary' | 'metric';
|
|
3
4
|
type Unit = (typeof UNITS)[number];
|
|
4
|
-
type UnitName = Unit[
|
|
5
|
-
type UnitAbbreviation = Unit[
|
|
5
|
+
type UnitName = Unit['name'];
|
|
6
|
+
type UnitAbbreviation = Unit['abbreviation'];
|
|
6
7
|
type UnitKey = UnitName | UnitAbbreviation;
|
|
7
8
|
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
8
9
|
type IngredientAmount = {
|
|
9
10
|
value: number;
|
|
10
11
|
unit: UnitKey;
|
|
11
12
|
};
|
|
12
|
-
type Ingredient
|
|
13
|
+
type Ingredient = {
|
|
13
14
|
name: string;
|
|
14
15
|
amount: IngredientAmount;
|
|
15
|
-
conversion?: Record<
|
|
16
|
+
conversion?: Partial<Record<ConversionTables, IngredientAmount | UnitKey>>;
|
|
16
17
|
notes?: string;
|
|
17
18
|
};
|
|
18
|
-
type
|
|
19
|
-
|
|
19
|
+
type Instruction = {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
image?: string;
|
|
20
23
|
};
|
|
21
|
-
type
|
|
24
|
+
type GlobalRecipeConfig = {};
|
|
25
|
+
type Recipe = GlobalRecipeConfig & {
|
|
22
26
|
name: string;
|
|
23
27
|
thumbnail?: string;
|
|
24
|
-
ingredients: Ingredient
|
|
25
|
-
|
|
28
|
+
ingredients: Ingredient[];
|
|
29
|
+
serves: number;
|
|
26
30
|
instructions: string[];
|
|
31
|
+
measurements?: ConversionTables;
|
|
27
32
|
};
|
|
28
|
-
type recipeOmittableKeys =
|
|
29
|
-
type RecipeConfig
|
|
33
|
+
type recipeOmittableKeys = 'serves';
|
|
34
|
+
type RecipeConfig = PartialBy<Recipe, recipeOmittableKeys>;
|
|
30
35
|
|
|
31
|
-
export type { GlobalRecipeConfig, Ingredient, IngredientAmount, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName };
|
|
36
|
+
export type { ConversionTables, GlobalRecipeConfig, Ingredient, IngredientAmount, Instruction, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName };
|
package/dist/types.d.ts
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
import { UNITS } from './const/unit.js';
|
|
2
2
|
|
|
3
|
+
type ConversionTables = 'us-customary' | 'metric';
|
|
3
4
|
type Unit = (typeof UNITS)[number];
|
|
4
|
-
type UnitName = Unit[
|
|
5
|
-
type UnitAbbreviation = Unit[
|
|
5
|
+
type UnitName = Unit['name'];
|
|
6
|
+
type UnitAbbreviation = Unit['abbreviation'];
|
|
6
7
|
type UnitKey = UnitName | UnitAbbreviation;
|
|
7
8
|
type PartialBy<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
8
9
|
type IngredientAmount = {
|
|
9
10
|
value: number;
|
|
10
11
|
unit: UnitKey;
|
|
11
12
|
};
|
|
12
|
-
type Ingredient
|
|
13
|
+
type Ingredient = {
|
|
13
14
|
name: string;
|
|
14
15
|
amount: IngredientAmount;
|
|
15
|
-
conversion?: Record<
|
|
16
|
+
conversion?: Partial<Record<ConversionTables, IngredientAmount | UnitKey>>;
|
|
16
17
|
notes?: string;
|
|
17
18
|
};
|
|
18
|
-
type
|
|
19
|
-
|
|
19
|
+
type Instruction = {
|
|
20
|
+
name: string;
|
|
21
|
+
description: string;
|
|
22
|
+
image?: string;
|
|
20
23
|
};
|
|
21
|
-
type
|
|
24
|
+
type GlobalRecipeConfig = {};
|
|
25
|
+
type Recipe = GlobalRecipeConfig & {
|
|
22
26
|
name: string;
|
|
23
27
|
thumbnail?: string;
|
|
24
|
-
ingredients: Ingredient
|
|
25
|
-
|
|
28
|
+
ingredients: Ingredient[];
|
|
29
|
+
serves: number;
|
|
26
30
|
instructions: string[];
|
|
31
|
+
measurements?: ConversionTables;
|
|
27
32
|
};
|
|
28
|
-
type recipeOmittableKeys =
|
|
29
|
-
type RecipeConfig
|
|
33
|
+
type recipeOmittableKeys = 'serves';
|
|
34
|
+
type RecipeConfig = PartialBy<Recipe, recipeOmittableKeys>;
|
|
30
35
|
|
|
31
|
-
export type { GlobalRecipeConfig, Ingredient, IngredientAmount, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName };
|
|
36
|
+
export type { ConversionTables, GlobalRecipeConfig, Ingredient, IngredientAmount, Instruction, Recipe, RecipeConfig, Unit, UnitAbbreviation, UnitKey, UnitName };
|
package/dist/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var r=Object.defineProperty;var
|
|
1
|
+
var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var m=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of s(e))!a.call(t,n)&&n!==o&&r(t,n,{get:()=>e[n],enumerable:!(i=p(e,n))||i.enumerable});return t};var y=t=>m(r({},"__esModule",{value:!0}),t);var g={};module.exports=y(g);
|
package/package.json
CHANGED
package/dist/chunk-4AN32V3Z.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as o}from"./chunk-SR2KFBT3.mjs";var r=class{convert(t,n){let m=o.convert(t.amount.value,t.amount.unit,n);return{...t,amount:{value:m,unit:n}}}};export{r as a};
|
package/dist/chunk-5ZCZ6LQB.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var o=process.env.NODE_ENV!=="production";export{o as a};
|
package/dist/chunk-BOG6H6FE.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as s}from"./chunk-C45UD45A.mjs";import{a as r}from"./chunk-3CSP4UZG.mjs";var t=class{scopedMessageFactory(e){return i=>`${e.name}: ${i}`}validateConfig(e){if(!!0)return;let i=this.scopedMessageFactory(e);s(e.instructions,n=>n.length>0,i("Recipe has no instructions")),s(e.servings,n=>n!==void 0&&n<=0,i("Recipe has less than one serving")),s(e.ingredients,n=>n.length>0,i("Recipe has no ingredients"))}create(e){return this.validateConfig(e),{name:e.name,ingredients:e.ingredients,servings:e.servings??1,instructions:e.instructions??[],units:e.units}}};export{t as a};
|
package/dist/chunk-CEPTOQUR.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c}from"./chunk-22RBQQWH.mjs";import{a as o}from"./chunk-C45UD45A.mjs";import{a,b as s}from"./chunk-KXFUCO3R.mjs";var b=class{static getUnit(t){let e=c.find(n=>n.abbreviation===t||n.name===t);return o(e,n=>!!n,`No unit found for key: ${t}`),e}static getConversionRatio(t,e){let{type:n,abbreviation:i}=this.getUnit(t),r=(n==="volume"?s:a)[i];return o(r,v=>!!v[e],`No conversion table available for unit ${t} to ${e}`),r[e]}static convert(t,e,n){if(e===n)return t;let i=this.getConversionRatio(e,n);return t*i}};export{b as a};
|
package/dist/chunk-EKLUF5ED.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{b as s}from"./chunk-C45UD45A.mjs";import{a as r}from"./chunk-3CSP4UZG.mjs";var t=class{scopedMessageFactory(e){return n=>`${e.name}: ${n}`}validateConfig(e){if(!0)return;let n=this.scopedMessageFactory(e);s(e.instructions,i=>i.length>0,n("Recipe has no instructions")),s(e.servings,i=>i!==void 0&&i<=0,n("Recipe has less than one serving")),s(e.ingredients,i=>i.length>0,n("Recipe has no ingredients"))}create(e){return this.validateConfig(e),{name:e.name,ingredients:e.ingredients,servings:e.servings??1,instructions:e.instructions??[]}}};export{t as a};
|
package/dist/chunk-LLHRB3T7.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as r}from"./chunk-3CSP4UZG.mjs";import{b as s}from"./chunk-C45UD45A.mjs";var t=class{scopedMessageFactory(e){return n=>`${e.name}: ${n}`}validateConfig(e){if(!0)return;let n=this.scopedMessageFactory(e);s(e.instructions,i=>i.length>0,n("Recipe has no instructions")),s(e.servings,i=>i!==void 0&&i<=0,n("Recipe has less than one serving")),s(e.ingredients,i=>i.length>0,n("Recipe has no ingredients"))}create(e){return this.validateConfig(e),{name:e.name,ingredients:e.ingredients,servings:e.servings??1,instructions:e.instructions??[]}}};export{t as a};
|
package/dist/chunk-MUILH2IA.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as o}from"./chunk-CEPTOQUR.mjs";var r=class{convert(t,n){let m=o.convert(t.amount.value,t.amount.unit,n);return{...t,amount:{value:m,unit:n}}}};export{r as a};
|
package/dist/chunk-YHBHNGQX.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as t}from"./chunk-5ZCZ6LQB.mjs";import{b as s}from"./chunk-C45UD45A.mjs";var r=class{scopedMessageFactory(e){return n=>`${e.name}: ${n}`}validateConfig(e){if(t)return;let n=this.scopedMessageFactory(e);s(e.instructions,i=>i.length>0,n("Recipe has no instructions")),s(e.servings,i=>i!==void 0&&i<=0,n("Recipe has less than one serving")),s(e.ingredients,i=>i.length>0,n("Recipe has no ingredients"))}create(e){return this.validateConfig(e),{name:e.name,ingredients:e.ingredients,servings:e.servings??1,instructions:e.instructions??[]}}};export{r as a};
|