@mark1russell7/stack-needs 0.9.4 → 0.9.6
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/README.md +62 -3
- package/build/index.d.ts +169 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +313 -36
- package/build/index.js.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ Each function is a plain function with no clock, no network and no file.
|
|
|
26
26
|
2. An age with no row in the tables gives a line with no read for that person, not an error. The total of `calorieNeed` is then a lower limit, and `read` is false.
|
|
27
27
|
3. The activity level is an explicit input. The package has no default level.
|
|
28
28
|
4. A stage of pregnancy or lactation is an input of a person record. `calorieNeed` adds the change of the stage to the need of the row. The change comes from the table of the row. A stage that this table does not have for the sex of the record is an error, not a no read. Thus the option `leave-out` cannot remove a pregnant person from a draw. One stage holds for each day of a call. For a period that crosses stages, the planner selects the stage, for example the stage with the largest change.
|
|
29
|
-
5. The cook converters come from the cited cook facts of the catalog
|
|
29
|
+
5. The cook converters come from the cited cook facts of the catalog and cited constants. The boil fuel comes from a cited stove share or a cited boil yield. A missing fact gives a no read, not a figure. Refer to the section on the water and the fuel of a cook.
|
|
30
30
|
|
|
31
31
|
`checkCalorieTable` is the gate of a table. It gives the findings of `checkSources` of `@mark1russell7/guidebook` for the source, also for a hash that is not 64 lowercase hexadecimal digits (`bad-sha256`). The source of a table must have a publisher (`by`), a page of its terms and a hash, and HTTPS addresses (the options `require` and `https` of the gate). A missing field gives `missing-field`. For the rows, it refuses two rows of one sex with ages in common, and a need that is not above 0 in `kcal/d`. The rows of each sex have no gap between two rows (`needs-gap`). A table can start after month 0 and end at a closed row. Each change has a stage, a title, a sex of the table and a finite value in `kcal/d`. Each stage and sex has one change at most (`needs-change`).
|
|
32
32
|
|
|
@@ -159,6 +159,8 @@ The fragment has no converter. Thus, with this fragment alone, only `food.no-coo
|
|
|
159
159
|
|
|
160
160
|
`cookFragment` gives the converters for the dry food in a different fragment, with the water and the fuel of each pot. Then `joinEndurance` joins the fragments. The dry food then adds days only while the water and the fuel last.
|
|
161
161
|
|
|
162
|
+
`formulaMixFragment` gives the converter of the infant formula powder in a different fragment, with its water. The powder then adds days of formula only while the water lasts.
|
|
163
|
+
|
|
162
164
|
This fragment declares the resource codes of the buy list, for example `water.stored` in `L`. A different fragment, for example the fragment of a water tank, can declare the same resource. `joinEndurance` of `@mark1russell7/stack-endurance` joins two equal records into one. A different unit is a fault of the join.
|
|
163
165
|
|
|
164
166
|
## The water and the fuel of a cook
|
|
@@ -185,6 +187,10 @@ The model of one pot:
|
|
|
185
187
|
1. The cook water is `cookWater` of `@mark1russell7/market` times the dry mass. It takes `water.stored`, the resource of the drinking water.
|
|
186
188
|
2. The heat to boil is the mass times 4.19002 kJ/(kg.K) times the rise to the boil (100 °C). The mass is the water and the dry food. The rise starts at the start temperature. This temperature is an input with its citation. The default is 0 °C, which gives the most heat. The dry food takes the specific heat of water, which is higher than its own. This term holds the heat above the true value.
|
|
187
189
|
3. The boil time is the heat divided by the stove rate times the stove share. The share is the part of the stove heat that goes into the water and the food. The heat of the pot itself is in the losses. It is a cited input with its heating value. It has no default.
|
|
190
|
+
A boil yield of the stove (`boil` of market) also gives the boil fuel, with no share and no fuel energy. The boil fuel is then the heat of the pot over the heat that 1 kg of fuel put into the test water.
|
|
191
|
+
The test water takes `WATER_DENSITY_MIN` (0.95865 kg/L at 100 °C, from the USGS table). The rise goes from the cited start to the cited end of the test.
|
|
192
|
+
Each choice gives the most fuel. At a high place the test water boils below 100 °C, so the end has no default.
|
|
193
|
+
The boil time is then the boil fuel over the mass rate. When the share and the yield both give a boil fuel, the line takes the most.
|
|
188
194
|
4. The stove time is the boil time plus the high end of the cook time. The cook time starts when the water boils.
|
|
189
195
|
5. The fuel is a safe upper limit: the stove burns at its full rate for all of the stove time. Only a stove rate with no bound gives the fuel. A rate with a bound, for example `bound: "least"`, gives a no read. At a high place the cook time is longer. The model does not give that time, so there the fuel is not an upper limit.
|
|
190
196
|
6. A rate in a mass gives the fuel mass directly. A rate in an energy gives a mass only through the cited energy of the fuel (`fuelEnergy`), with the same heating value.
|
|
@@ -198,7 +204,8 @@ Each value of a line is a read or a no read with its reasons. These facts give a
|
|
|
198
204
|
| No cited cook time | The stove time and the fuel. |
|
|
199
205
|
| No cited stove rate, or a rate that is not an energy or a mass in a time | The stove time and the fuel. |
|
|
200
206
|
| A stove rate with a bound, for example `bound: "least"` of market | The stove time and the fuel. The fuel of the cook time is the rate times the time, so a least rate gives too little fuel. |
|
|
201
|
-
| No cited stove share | The stove time and the fuel. The water and the heat keep their reads. |
|
|
207
|
+
| No cited stove share, and no boil yield with a read | The stove time and the fuel. The water and the heat keep their reads. |
|
|
208
|
+
| A boil yield with the bound `most`, or with no cited start or end temperature | No boil fuel from the yield. A most yield, for example the calm test of a maker, gives too little fuel for the boil. |
|
|
202
209
|
| A heating value of the share or of the rate that is not the heating value of the fuel energy | The stove time and the fuel. |
|
|
203
210
|
| No cited energy of the fuel, with a rate in an energy or a share on a rate in a mass | The stove time and the fuel. |
|
|
204
211
|
| No food energy of the product | The energy. |
|
|
@@ -220,6 +227,58 @@ The cited constants:
|
|
|
220
227
|
|
|
221
228
|
The two sources are works of the United States federal government (the license `us-public-domain` of guidebook).
|
|
222
229
|
|
|
230
|
+
## The water of infant formula powder
|
|
231
|
+
|
|
232
|
+
`formulaMixFragment` turns the infant formula powder of a buy list into one converter of an endurance layer. The converter needs no fuel. One run is 1 kg of powder. The run takes the powder and its mix water, and gives the energy of the powder as ready formula. Thus a powder with no water gives no feed.
|
|
233
|
+
|
|
234
|
+
```ts
|
|
235
|
+
import { SUPPLY_CATALOG } from "@mark1russell7/market/supplies";
|
|
236
|
+
import { formulaMixFragment } from "@mark1russell7/stack-needs";
|
|
237
|
+
|
|
238
|
+
const mix = formulaMixFragment({ catalog: SUPPLY_CATALOG, units: { "food.infant-formula-powder-1kg": 2 } });
|
|
239
|
+
// mix.layer has the converter mix:food.infant-formula-powder. Join it with the layer of householdFragment and a store of water.
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
The records of the converter:
|
|
243
|
+
|
|
244
|
+
| Field | Value for 1 kg of the catalog powder |
|
|
245
|
+
| --- | --- |
|
|
246
|
+
| `takes` | 1 kg of `food.infant-formula-powder`, and 7.3175 L of `water.stored` |
|
|
247
|
+
| `gives` | 5240 kcal of `food.infant-formula-ready`, the resource of the ready formula |
|
|
248
|
+
| `id` | `mix:food.infant-formula-powder`. The option `prefix` changes the start. |
|
|
249
|
+
|
|
250
|
+
The direct use of `food.infant-formula-ready` then feeds the formula draw. The powder has a store in the household fragment, and no direct use. `cookFragment` does not cook it.
|
|
251
|
+
|
|
252
|
+
### The mix rule
|
|
253
|
+
|
|
254
|
+
The rule is a mass balance. It assumes that the prepared powder has the energy in 100 g of the ready-to-feed item of the same store brand. The reason: FoodData Central gives these two items of one brand, and no catalog record cites the mix ratio of a label. A label-cited mix ratio replaces this assumption.
|
|
255
|
+
|
|
256
|
+
1. The powder gives 524 kcal in 100 g, and the ready-to-feed item gives 63 kcal in 100 g.
|
|
257
|
+
2. Thus 100 g of prepared formula holds 100 × 63 / 524 = 12.023 g of powder and 87.977 g of mix water.
|
|
258
|
+
3. The mix water is 1.39646 g for each kcal, and 7.3175 kg for each kg of powder (`formulaMixWater`).
|
|
259
|
+
4. The water mass converts to a volume at `WATER_DENSITY_MAX`, 1 kg/L. Water above 4 °C is less dense, so the true volume is a little more.
|
|
260
|
+
5. The energy of each powder product comes from its food energy in the catalog. Two products can give powder. Then the converter takes the most water and the least energy of their lines.
|
|
261
|
+
|
|
262
|
+
`formulaMixCheck` gives an independent check of the rule. The rule does not use the water of the two items. The powder holds 2 g of water in 100 g, thus 0.240 g in 12.023 g. The predicted water of 100 g of prepared formula is 87.977 + 0.240 = 88.218 g. The FDC item 172319 gives 88.1 g, 0.13% less.
|
|
263
|
+
|
|
264
|
+
These facts give a no read, and then the powder has no converter:
|
|
265
|
+
|
|
266
|
+
| Missing fact | The no read |
|
|
267
|
+
| --- | --- |
|
|
268
|
+
| No food energy of the product, or an energy in a unit that does not convert to kcal | The energy and the water |
|
|
269
|
+
| A product that gives more than one food | The energy and the water |
|
|
270
|
+
| An energy of the powder that is not more than the 630 kcal/kg of the ready-to-feed item | The water |
|
|
271
|
+
|
|
272
|
+
The water is `water.stored`, the store of the drinking water, as for a cook. The WIC guide tells to use bottled water after a disaster or in a power cut. A store of water from the tap is safe water only when its source is safe. A drinking draw at a higher level takes its water first. Thus, when a case cuts the water supply, the powder can add 0 days.
|
|
273
|
+
|
|
274
|
+
The WIC guide tells to prepare powder one bottle at a time, for one feed. Thus the mix has no waste of an opened container. The rule of opened containers applies only to a product with the field `opened`.
|
|
275
|
+
|
|
276
|
+
The cited constant:
|
|
277
|
+
|
|
278
|
+
| Name | Value | Source |
|
|
279
|
+
| --- | --- | --- |
|
|
280
|
+
| `FORMULA_MIX` | 524 kcal and 2 g of water in 100 g of powder. 63 kcal and 88.1 g of water in 100 g of ready-to-feed formula. | FoodData Central, SR Legacy (April 2018, CC0 1.0): FDC ID 173554 (store brand, powder) and FDC ID 172319 (store brand, ready-to-feed), `food_nutrient.csv`. The water source is the WIC guide, page 106. |
|
|
281
|
+
|
|
223
282
|
## The uses, the supply parts and the join gate
|
|
224
283
|
|
|
225
284
|
The package holds one record of each use and of each default supply part. `householdFragment` takes its food use from `DIRECT_USES`.
|
|
@@ -305,4 +364,4 @@ The gate refuses an empty code and two needs with one code (`daily-need-id`). It
|
|
|
305
364
|
|
|
306
365
|
| Entry | What it has |
|
|
307
366
|
| --- | --- |
|
|
308
|
-
| `@mark1russell7/stack-needs` | The records, the calorie tables and `CALORIE_CHAIN`, the gates, `calorieNeed`, `householdFragment`, `cookFragment` and its constants, the uses, the supply parts and `checkJoins`. |
|
|
367
|
+
| `@mark1russell7/stack-needs` | The records, the calorie tables and `CALORIE_CHAIN`, the gates, `calorieNeed`, `householdFragment`, `cookFragment` and its constants, `formulaMixFragment` and `FORMULA_MIX`, the uses, the supply parts and `checkJoins`. |
|
package/build/index.d.ts
CHANGED
|
@@ -190,7 +190,7 @@ export interface CitedFeeds {
|
|
|
190
190
|
* 24 hours divided by 3 hours is 8. More feeds give smaller feeds and thus more waste, so this value is the most feeds.
|
|
191
191
|
*/
|
|
192
192
|
export declare const FORMULA_FEEDS: CitedFeeds;
|
|
193
|
-
/** The source of the energy
|
|
193
|
+
/** The source of the energy and the water of the infant formula items: the SR Legacy file of FoodData Central. */
|
|
194
194
|
export declare const FDC_SR_LEGACY_SOURCE: Source;
|
|
195
195
|
/** The energy of the least formula of one infant for one day, from a cited volume and a cited energy of one fluid ounce. */
|
|
196
196
|
export interface CitedFormulaLeast {
|
|
@@ -208,6 +208,31 @@ export interface CitedFormulaLeast {
|
|
|
208
208
|
* and 24 ounces at 8 to 12 months. The FDC item 172319 gives 63 kcal in 100 g and 30.4 g in 1 fl oz, thus 19.152 kcal in 1 fl oz.
|
|
209
209
|
*/
|
|
210
210
|
export declare const FORMULA_LATER_LEAST: CitedFormulaLeast;
|
|
211
|
+
/**
|
|
212
|
+
* The facts of the mix rule: the energy and the water of a powder and of a ready-to-feed item of one store brand.
|
|
213
|
+
* `formulaMixWater` gives the rule, and `formulaMixCheck` gives its check.
|
|
214
|
+
*/
|
|
215
|
+
export interface CitedFormulaMix {
|
|
216
|
+
/** The energy of the powder, in `kcal` in 100 g. */
|
|
217
|
+
readonly powderKcal: number;
|
|
218
|
+
/** The water of the powder, in `g` in 100 g. Only the check of the rule uses it. */
|
|
219
|
+
readonly powderWater: number;
|
|
220
|
+
/** The energy of the ready-to-feed item, in `kcal` in 100 g. */
|
|
221
|
+
readonly readyKcal: number;
|
|
222
|
+
/** The water of the ready-to-feed item, in `g` in 100 g. Only the check of the rule uses it. */
|
|
223
|
+
readonly readyWater: number;
|
|
224
|
+
readonly source: Source;
|
|
225
|
+
readonly locator: string;
|
|
226
|
+
/** The source that tells to mix the powder with safe water, one bottle at a time. */
|
|
227
|
+
readonly waterSource: Source;
|
|
228
|
+
readonly waterLocator: string;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* The facts of the mix rule: the FDC items 173554 (store brand, powder) and 172319 (store brand, ready-to-feed).
|
|
232
|
+
* The powder gives 524 kcal and 2 g of water in 100 g. The ready-to-feed item gives 63 kcal and 88.1 g of water in 100 g.
|
|
233
|
+
* The WIC guide tells to mix powder one bottle at a time, and to use bottled water after a disaster or in a power cut.
|
|
234
|
+
*/
|
|
235
|
+
export declare const FORMULA_MIX: CitedFormulaMix;
|
|
211
236
|
/** The source of the infant table: the PDF of the report Dietary Reference Intakes for Energy (2023) of the National Academies. */
|
|
212
237
|
export declare const NASEM_ENERGY_SOURCE: Source;
|
|
213
238
|
/** The energy of the breast milk of one infant for one day, with its source and its place in the source. */
|
|
@@ -297,6 +322,11 @@ export declare const WATER_NEED = "hydration.drink";
|
|
|
297
322
|
export declare const NO_COOK = "food.no-cook";
|
|
298
323
|
/** The resource of the ready-to-feed infant formula, in `kcal`. It has a direct use for the formula need. It needs no water and no fuel. */
|
|
299
324
|
export declare const FORMULA_READY = "food.infant-formula-ready";
|
|
325
|
+
/**
|
|
326
|
+
* The resource of the infant formula powder, in `kg`. It has no direct use. `formulaMixFragment` mixes it with
|
|
327
|
+
* `STORED_WATER` into `FORMULA_READY`. `cookFragment` does not cook it.
|
|
328
|
+
*/
|
|
329
|
+
export declare const FORMULA_POWDER = "food.infant-formula-powder";
|
|
300
330
|
/** The resource of the stored drinking water, in `L`. It has a direct use for the water need. */
|
|
301
331
|
export declare const STORED_WATER = "water.stored";
|
|
302
332
|
/** The direct use of a resource for a need: 1 unit of the resource gives `amount` of the need. */
|
|
@@ -551,6 +581,7 @@ export type HouseholdFragmentResult = HouseholdFragmentRead | HouseholdFragmentN
|
|
|
551
581
|
* - The resources are the resources of the stores and of the direct uses, with the units of the catalog.
|
|
552
582
|
* - The supply part of each draw is `supply`. Its default is the part of `NEED_SUPPLIES` for the need of the draw.
|
|
553
583
|
* - The fragment has no converter. `cookFragment` gives the converters for the dry food, with the water and the fuel of each pot.
|
|
584
|
+
* `formulaMixFragment` gives the converter of `food.infant-formula-powder`. The powder has a store, and no direct use.
|
|
554
585
|
* - With no cold storage (the default), an opened container of formula serves one feed. The store has only the energy of the feeds,
|
|
555
586
|
* and `waste` gives the rest. The smallest feed is the smallest need of an infant of the draw, divided by `FORMULA_FEEDS`.
|
|
556
587
|
* A container of no read gives no store and a gift with no read, so the stores are a lower limit.
|
|
@@ -609,6 +640,11 @@ export declare const WATER_SPECIFIC_HEAT: CookConstant;
|
|
|
609
640
|
* Thus 1 L of cook water is 1 kg or less.
|
|
610
641
|
*/
|
|
611
642
|
export declare const WATER_DENSITY_MAX: CookConstant;
|
|
643
|
+
/**
|
|
644
|
+
* The least density of liquid water from 0 °C to 100 °C: 0.95865 kg/L. The USGS table gives 0.95865 g/cm3 at 100 °C, its least value.
|
|
645
|
+
* Thus 1 L of the test water of a boil yield is 0.95865 kg or more. The least mass of the test water gives the most fuel for each kg of the pot.
|
|
646
|
+
*/
|
|
647
|
+
export declare const WATER_DENSITY_MIN: CookConstant;
|
|
612
648
|
/**
|
|
613
649
|
* The temperature at the end of the heat to boil, in °C.
|
|
614
650
|
* Water boils at a lower temperature at a high place. Then the heat is less.
|
|
@@ -650,7 +686,10 @@ export interface CookFragmentInput {
|
|
|
650
686
|
* Give the smallest pot that the cook makes. A batch above the real pot gives too little fuel, because each pot takes its own cook time.
|
|
651
687
|
*/
|
|
652
688
|
readonly batch: Quantity;
|
|
653
|
-
/**
|
|
689
|
+
/**
|
|
690
|
+
* The stove share. It has no default. Without it, only a boil yield of the stove gives the fuel of the boil.
|
|
691
|
+
* Without a share and a yield with a read, each fuel is a no read.
|
|
692
|
+
*/
|
|
654
693
|
readonly share?: StoveShare | undefined;
|
|
655
694
|
/** The start temperature of the cook water. The default is `COLD_START_CELSIUS`. */
|
|
656
695
|
readonly start?: CookStart | undefined;
|
|
@@ -734,12 +773,18 @@ export interface CookFragmentResult {
|
|
|
734
773
|
* - The heat to boil is the mass of the water and the dry food times `WATER_SPECIFIC_HEAT` times the rise from the start to `BOIL_CELSIUS`.
|
|
735
774
|
* The water mass takes `WATER_DENSITY_MAX`. The dry food takes the specific heat of water, which is higher than its own.
|
|
736
775
|
* - The boil time is the heat divided by the stove rate times the share. The time of the stove is the boil time plus the high end of the cook time.
|
|
776
|
+
* - A boil yield of the stove (`boil` of market) gives the boil fuel with no share and no fuel energy.
|
|
777
|
+
* The boil fuel is the heat of the pot over the heat of 1 kg of fuel in the test.
|
|
778
|
+
* The test water takes `WATER_DENSITY_MIN`, and the rise goes from the cited start to the cited end of the test. The boil time is then the boil fuel over the mass rate.
|
|
779
|
+
* A yield with the bound `most`, or with no cited start or end, gives a no read. When the share and the yield both have a read, the line takes the most boil fuel.
|
|
737
780
|
* - The fuel is a safe upper limit: the stove burns at its full rate for all of that time. At a high place the cook time is longer.
|
|
738
781
|
* The model does not give that time, so there the fuel is not an upper limit.
|
|
739
782
|
* - Only a stove rate with no bound gives the fuel. A rate with a bound, for example `bound: "least"`, gives a no read. The fuel of the cook time is the rate times the time, so a least rate gives too little fuel.
|
|
740
783
|
* - A rate in a mass gives the fuel directly. A rate in an energy gives a mass only through the cited energy of the fuel, with the same heating value.
|
|
741
784
|
*
|
|
742
|
-
* A dry food is a gift of a food resource in a unit of mass
|
|
785
|
+
* A dry food is a gift of a food resource in a unit of mass, except `FORMULA_POWDER`. `formulaMixFragment` gives its converter.
|
|
786
|
+
* Each missing fact gives a line with no read and its reasons, not a figure.
|
|
787
|
+
*
|
|
743
788
|
* Two products of the list can give one dry resource, for example rice and oats. The converter then takes the worst case of their lines:
|
|
744
789
|
* the most water, the most fuel and the least food energy. When a line of the resource has no read, the resource has no converter.
|
|
745
790
|
* A store of the resource from a different fragment gets the converter of this list.
|
|
@@ -764,6 +809,127 @@ export interface CookFragmentResult {
|
|
|
764
809
|
* @throws RangeError for the errors of `giftsOf`
|
|
765
810
|
*/
|
|
766
811
|
export declare function cookFragment(input: CookFragmentInput): CookFragmentResult;
|
|
812
|
+
/**
|
|
813
|
+
* This function gives the mix water of infant formula powder, in `kg` for each `kg` of powder.
|
|
814
|
+
*
|
|
815
|
+
* The rule is a mass balance. It assumes that the prepared powder has the energy in 100 g of the ready-to-feed item of the
|
|
816
|
+
* same store brand. The reason: the FDC file gives these two items of one brand, and the catalog cites no mix ratio of a label.
|
|
817
|
+
* The assumption ends when a label-cited mix ratio replaces it.
|
|
818
|
+
*
|
|
819
|
+
* Thus 1 kg of powder gives `powder / ready` kg of prepared formula, and the water is that mass minus 1 kg.
|
|
820
|
+
* For `FORMULA_MIX`, 5240 kcal/kg divided by 630 kcal/kg gives 8.3175 kg, so the water is 7.3175 kg. That is 1.39646 g for each kcal.
|
|
821
|
+
* `formulaMixCheck` compares the water of the prepared formula with the cited water of the ready-to-feed item.
|
|
822
|
+
*
|
|
823
|
+
* @param powderKcalPerKg - The energy of the powder, in `kcal/kg`, for example 5240
|
|
824
|
+
* @param mix - The facts of the rule. The default is `FORMULA_MIX`. Only its energy of the ready-to-feed item applies.
|
|
825
|
+
* @returns The mass of the mix water, in kg for each kg of powder
|
|
826
|
+
* @throws RangeError when the energy of the powder is not above the energy of the ready-to-feed item
|
|
827
|
+
*/
|
|
828
|
+
export declare function formulaMixWater(powderKcalPerKg: number, mix?: CitedFormulaMix): number;
|
|
829
|
+
/** The check of the mix rule: the water in 100 g of prepared formula from the rule, and the cited water of the ready-to-feed item. */
|
|
830
|
+
export interface FormulaMixCheck {
|
|
831
|
+
/** The powder in 100 g of prepared formula, in `g`. */
|
|
832
|
+
readonly powder: number;
|
|
833
|
+
/** The mix water in 100 g of prepared formula, in `g`. */
|
|
834
|
+
readonly added: number;
|
|
835
|
+
/** The water in 100 g of prepared formula, in `g`: the mix water and the water of the powder. */
|
|
836
|
+
readonly predicted: number;
|
|
837
|
+
/** The cited water in 100 g of the ready-to-feed item, in `g`. */
|
|
838
|
+
readonly cited: number;
|
|
839
|
+
/** The difference of `predicted` and `cited`, divided by `cited`. */
|
|
840
|
+
readonly relative: number;
|
|
841
|
+
}
|
|
842
|
+
/**
|
|
843
|
+
* This function gives the check of the mix rule with the water of the two items. The rule does not use their water, so the
|
|
844
|
+
* check is independent of it. For `FORMULA_MIX`, 100 g of prepared formula has 12.023 g of powder and 87.977 g of mix water.
|
|
845
|
+
* The powder holds 0.240 g of water, so the prediction is 88.218 g. The FDC item gives 88.1 g, 0.13% less.
|
|
846
|
+
*
|
|
847
|
+
* @param mix - The facts of the rule. The default is `FORMULA_MIX`.
|
|
848
|
+
* @returns The predicted water, the cited water and their relative difference
|
|
849
|
+
* @throws RangeError for the errors of `formulaMixWater`
|
|
850
|
+
*/
|
|
851
|
+
export declare function formulaMixCheck(mix?: CitedFormulaMix): FormulaMixCheck;
|
|
852
|
+
/** The inputs of the mix fragment. */
|
|
853
|
+
export interface FormulaMixInput {
|
|
854
|
+
/** The catalog of supplies of `@mark1russell7/market`. */
|
|
855
|
+
readonly catalog: SupplyCatalog;
|
|
856
|
+
/** The count of units of each product of the buy list, by the `id` of the product. */
|
|
857
|
+
readonly units: Readonly<Record<string, number>>;
|
|
858
|
+
/** The facts of the mix rule. The default is `FORMULA_MIX`. */
|
|
859
|
+
readonly mix?: CitedFormulaMix | undefined;
|
|
860
|
+
/** The start of the `id` of the converter. The default is `mix`. */
|
|
861
|
+
readonly prefix?: string | undefined;
|
|
862
|
+
}
|
|
863
|
+
/** The mix values of one product of the buy list that gives `FORMULA_POWDER`, for 1 kg of powder. */
|
|
864
|
+
export interface FormulaMixLine {
|
|
865
|
+
readonly product: string;
|
|
866
|
+
/** The energy of the powder, in `kcal/kg`. */
|
|
867
|
+
readonly energy: CookRead;
|
|
868
|
+
/** The mix water, in `L/kg` of powder. */
|
|
869
|
+
readonly water: CookRead;
|
|
870
|
+
}
|
|
871
|
+
/** The converter of the mix fragment, with the form of `Converter` of `@mark1russell7/stack-endurance`. It gives a resource, not a need. */
|
|
872
|
+
export interface MixConverter {
|
|
873
|
+
readonly id: string;
|
|
874
|
+
readonly takes: readonly {
|
|
875
|
+
readonly resource: string;
|
|
876
|
+
readonly amount: number;
|
|
877
|
+
}[];
|
|
878
|
+
readonly gives: {
|
|
879
|
+
readonly resource: string;
|
|
880
|
+
readonly amount: number;
|
|
881
|
+
};
|
|
882
|
+
}
|
|
883
|
+
/** The mix fragment of an endurance layer: the resources and one converter, or none. It has no store and no draw. */
|
|
884
|
+
export interface MixFragment {
|
|
885
|
+
/** The format of an endurance layer, `endurance/1`. */
|
|
886
|
+
readonly schema: "endurance/1";
|
|
887
|
+
readonly levels: readonly string[];
|
|
888
|
+
readonly resources: readonly {
|
|
889
|
+
readonly code: string;
|
|
890
|
+
readonly unit: string;
|
|
891
|
+
}[];
|
|
892
|
+
readonly stores: readonly never[];
|
|
893
|
+
readonly draws: readonly never[];
|
|
894
|
+
readonly converters: readonly MixConverter[];
|
|
895
|
+
}
|
|
896
|
+
/** The mix fragment, the line of each powder product and the reason when the powder has no converter. */
|
|
897
|
+
export interface FormulaMixResult {
|
|
898
|
+
readonly layer: MixFragment;
|
|
899
|
+
/** The line of each product of the buy list that gives `FORMULA_POWDER`, in the order of the list. */
|
|
900
|
+
readonly lines: readonly FormulaMixLine[];
|
|
901
|
+
/** The reasons when the buy list has powder and the powder has no converter. Otherwise `undefined`. */
|
|
902
|
+
readonly why: string | undefined;
|
|
903
|
+
/** True when the powder of the buy list has a converter, or when the list has no powder. */
|
|
904
|
+
readonly read: boolean;
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* This function gives the converter that mixes the infant formula powder of a buy list with water, with no fuel.
|
|
908
|
+
*
|
|
909
|
+
* - One run of the converter is 1 kg of powder. It takes the powder and the mix water from `water.stored`.
|
|
910
|
+
* It gives the energy of the powder as `food.infant-formula-ready`. The direct use of that resource feeds the formula need.
|
|
911
|
+
* - The mix water is `formulaMixWater`: a mass balance with the energy of the ready-to-feed item of the same store brand.
|
|
912
|
+
* This is an assumption. A label-cited mix ratio replaces it.
|
|
913
|
+
* - The mass of the water converts to a volume at `WATER_DENSITY_MAX`, 1 kg/L. Water above 4 °C is less dense, so the true volume is a little more.
|
|
914
|
+
* - The water is `water.stored`, the store of the drinking water. The WIC guide tells to use bottled water after a disaster
|
|
915
|
+
* or in a power cut. A store of water from the tap is safe water only when its source is safe.
|
|
916
|
+
* - The WIC guide tells to prepare powder one bottle at a time, for one feed. Thus the mix has no waste of an opened container.
|
|
917
|
+
* - The powder of each product comes from its food energy in the catalog. Two products of the list can give powder.
|
|
918
|
+
* The converter then takes the worst case of their lines: the most water and the least energy. A line with no read gives no converter.
|
|
919
|
+
* - A drinking draw at a higher level of the same store takes its water first, by the take order of `enduranceOf`.
|
|
920
|
+
* Thus, when a case cuts the water supply, the powder can add 0 days.
|
|
921
|
+
*
|
|
922
|
+
* The function is pure.
|
|
923
|
+
*
|
|
924
|
+
* @param input - The catalog and the buy list, and the facts of the mix rule
|
|
925
|
+
* @returns The fragment, the line of each powder product and the reasons for no converter
|
|
926
|
+
* @throws RangeError when the catalog has no product of an `id` of the buy list
|
|
927
|
+
* @throws RangeError when the powder has a converter and the catalog has no `food.infant-formula-powder` in a unit of mass
|
|
928
|
+
* @throws RangeError when the powder has a converter and the catalog has no `food.infant-formula-ready` in a unit of energy
|
|
929
|
+
* @throws RangeError when the powder has a converter and the catalog has no `water.stored` in a unit of volume
|
|
930
|
+
* @throws RangeError for the errors of `giftsOf`
|
|
931
|
+
*/
|
|
932
|
+
export declare function formulaMixFragment(input: FormulaMixInput): FormulaMixResult;
|
|
767
933
|
/** The code of the need of light to see in the dark in a home, in hours. */
|
|
768
934
|
export declare const LIGHT_NEED = "light.see";
|
|
769
935
|
/** The code of the need of an alert receiver that is on, in hours. */
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/calorie.ts","../src/data.ts","../src/check.ts","../src/uses.ts","../src/household.ts","../src/cook.ts","../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