@mark1russell7/stack-needs 0.9.6 → 0.9.8

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 CHANGED
@@ -213,7 +213,7 @@ Each value of a line is a read or a no read with its reasons. These facts give a
213
213
 
214
214
  A dry resource with a no read in a line has no converter. It is in `noReads`, and `read` is false. 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: the most water, the most fuel and the least energy.
215
215
 
216
- The catalog of market gives no soak water. Thus a food that needs a soak, for example dry beans, has no soak draw. The beans of the catalog have no cited cook water, so they have no converter.
216
+ Market gives the soak water of a dry food with `soakWater`. This function does not take it. Thus the water of a food with a soak, for example dry beans, is a lower limit. The cook water of beans and pasta gives their converters.
217
217
 
218
218
  The cook water and the drinking water are one store, `water.stored`. A drinking draw at a higher level takes its water first, by the take order of `enduranceOf`. The drinking draw keeps back its days times its demand, which is all of the store. Thus, when a case cuts the water supply, the dry food adds 0 days at each amount of stored water.
219
219
 
@@ -360,8 +360,20 @@ The 2025-2030 edition of the guidelines was read on 2026-11-24. It has no table
360
360
 
361
361
  The gate refuses an empty code and two needs with one code (`daily-need-id`). It refuses a unit that `@mark1russell7/quantity` does not read (`daily-need-unit`). It also refuses a bad read or a no read with no reason (`daily-need-rate`). A bad read has no source. Or its amount is not a finite number of 0 or more in the unit of the need for each day.
362
362
 
363
+ ## The devices of the kit
364
+
365
+ `deviceFragment` gives the devices of a buy list that run on cells, as converters of an endurance layer. Examples are a radio and a flashlight.
366
+
367
+ - Each device of the catalog of market with a cited run time gives one converter. The field `device` of a product gives its need, its cells and its run time.
368
+ - One run takes one cell, and gives the hours of the need for each cell. For example, 48 h on 3 cells gives 16 h for each cell.
369
+ - One device gives its need for 24 hours in a day or less. Thus the limit `perDay` is `HOURS_IN_DAY` divided by the hours for each cell. The count of devices is the count of whole units.
370
+ - The input `runs` gives the run time of a device of the caller, with its citation. It replaces the run time of the catalog.
371
+ - A device with no run time gives no converter, and a no read. The radio and the flashlight of the catalog are no one model, so their run time is a no read.
372
+ - With the input `draws`, each need of a device gives one draw at the daily rate of the need. A need with no read of its rate gives no draw, and a no read.
373
+ - The fragment has no store. The cells come from the stores of the buy list, for example the product `power.aa-alkaline` of the catalog.
374
+
363
375
  ## The entries
364
376
 
365
377
  | Entry | What it has |
366
378
  | --- | --- |
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`. |
379
+ | `@mark1russell7/stack-needs` | The records, the calorie tables and `CALORIE_CHAIN`, the gates, `calorieNeed`, `householdFragment`, `cookFragment` and its constants, `formulaMixFragment` and `FORMULA_MIX`, `deviceFragment`, the daily needs, the uses, the supply parts and `checkJoins`. |
package/build/index.d.ts CHANGED
@@ -789,7 +789,7 @@ export interface CookFragmentResult {
789
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.
790
790
  * A store of the resource from a different fragment gets the converter of this list.
791
791
  *
792
- * The catalog of market gives no soak water. A food that needs a soak, for example dry beans, has a second water draw that this function does not give.
792
+ * Market gives the soak water of a dry food with `soakWater`. This function does not take it. Thus the water of a food with a soak, for example dry beans, is a lower limit.
793
793
  * A product that gives more than one food has no energy for each food, so its energy is a no read.
794
794
  *
795
795
  * The cook water is `water.stored`, the store of the drinking water. A drinking draw at a higher level of the same store takes
@@ -997,4 +997,111 @@ export type DailyNeedFinding = Finding<DailyNeedCode | FindingCode, "source" | "
997
997
  * @param options - The options of the gate of the sources, for example the date of the gate
998
998
  */
999
999
  export declare function checkDailyNeeds(needs: readonly DailyNeed[], options?: GateOptions): DailyNeedFinding[];
1000
+ /** The hours in one day, from the definition of the day in `@mark1russell7/quantity`. */
1001
+ export declare const HOURS_IN_DAY: number;
1002
+ /** The run time of a device of the caller: `amount` of `unit` on `per` cells, with its citation. */
1003
+ export interface DeviceRun {
1004
+ readonly amount: number;
1005
+ readonly unit: string;
1006
+ readonly per: {
1007
+ readonly amount: number;
1008
+ readonly unit: string;
1009
+ };
1010
+ /** The citation of the value: the `id` of a fact or a source of the caller. */
1011
+ readonly cite: string;
1012
+ }
1013
+ /** The part of the stack that supplies the needs of the devices, and the level of their draws. */
1014
+ export interface DeviceDraws {
1015
+ readonly level: string;
1016
+ readonly supply: string;
1017
+ }
1018
+ /** The inputs of the device fragment. */
1019
+ export interface DeviceFragmentInput {
1020
+ /** The catalog of supplies of `@mark1russell7/market`. */
1021
+ readonly catalog: SupplyCatalog;
1022
+ /** The count of units of each product of the buy list or the kit, by the `id` of the product. */
1023
+ readonly units: Readonly<Record<string, number>>;
1024
+ /**
1025
+ * The run time of each device of the caller, by the `id` of the product. It replaces the run time of the catalog, for
1026
+ * example for a model that the catalog does not cite. It has no default.
1027
+ */
1028
+ readonly runs?: Readonly<Record<string, DeviceRun>> | undefined;
1029
+ /** The `id` of each device in the stack, by the `id` of the product. The converter stops when the device stops. */
1030
+ readonly parts?: Readonly<Record<string, string>> | undefined;
1031
+ /** The level and the supply of the draws. Without it, the fragment has no draw. */
1032
+ readonly draws?: DeviceDraws | undefined;
1033
+ /** The daily needs. The default is `DAILY_NEEDS`. */
1034
+ readonly needs?: readonly DailyNeed[] | undefined;
1035
+ /** The start of the `id` of each converter. The default is `device`. */
1036
+ readonly prefix?: string | undefined;
1037
+ }
1038
+ /** A value of the device model with a read, in its unit, or no read with the reasons. A no read is not 0. */
1039
+ export type DeviceRead = {
1040
+ readonly read: true;
1041
+ readonly value: number;
1042
+ readonly unit: string;
1043
+ } | {
1044
+ readonly read: false;
1045
+ readonly why: string;
1046
+ };
1047
+ /** The values of one device of the buy list. */
1048
+ export interface DeviceLine {
1049
+ readonly product: string;
1050
+ /** The code of the need that the device gives, for example `alert.watch`. */
1051
+ readonly need: string;
1052
+ /** The resource of its cells, for example `battery.aa`. */
1053
+ readonly battery: string;
1054
+ /** The count of whole devices. */
1055
+ readonly devices: number;
1056
+ /** The hours of the need for each cell, in `h`. */
1057
+ readonly hours: DeviceRead;
1058
+ }
1059
+ /** A converter of the device fragment: a converter with its limit of runs for each day and its count of devices. */
1060
+ export interface DeviceConverter extends FragmentConverter {
1061
+ readonly perDay: number;
1062
+ readonly devices: number;
1063
+ }
1064
+ /** The device fragment of an endurance layer: the resources, one converter for each device with a read, and the draws. It has no store. */
1065
+ export interface DeviceFragment {
1066
+ /** The format of an endurance layer, `endurance/1`. */
1067
+ readonly schema: "endurance/1";
1068
+ readonly levels: readonly string[];
1069
+ readonly resources: readonly FragmentResource[];
1070
+ readonly stores: readonly never[];
1071
+ readonly draws: readonly FragmentDraw[];
1072
+ readonly converters: readonly DeviceConverter[];
1073
+ }
1074
+ /** A device or a need with no record in the layer, and the reasons. `product` names a device, and `need` names a draw. */
1075
+ export type DeviceNoRead = {
1076
+ readonly product: string;
1077
+ readonly need?: never;
1078
+ readonly why: string;
1079
+ } | {
1080
+ readonly need: string;
1081
+ readonly product?: never;
1082
+ readonly why: string;
1083
+ };
1084
+ /** The device fragment, the line of each device and the records with no read. */
1085
+ export interface DeviceFragmentResult {
1086
+ readonly layer: DeviceFragment;
1087
+ /** The line of each device of the buy list, in the order of the list. */
1088
+ readonly lines: readonly DeviceLine[];
1089
+ /** The devices with no converter, and the needs with no draw. */
1090
+ readonly noReads: readonly DeviceNoRead[];
1091
+ /** True when each device has a converter and each need has a draw. When it is false, the days of a need are a lower limit or a no read. */
1092
+ readonly read: boolean;
1093
+ }
1094
+ /**
1095
+ * This function gives the device fragment of an endurance layer. Each device of the buy list with a cited run time gives
1096
+ * one converter. One run takes one cell and gives the hours of the need for each cell. The limit of runs for each day is
1097
+ * `HOURS_IN_DAY` divided by those hours. Thus one device gives 24 hours of its need in a day or less. The count of
1098
+ * devices is the count of whole units of the product. A device with no cited run time gives no converter, and a no read.
1099
+ *
1100
+ * With `draws`, each need of a device gives one draw. Its rate is the daily rate of the need in its unit for each day. The users are 1
1101
+ * for a need of the household. A need with no read of its rate gives no draw, and a no read.
1102
+ *
1103
+ * @param input - The catalog, the counts of the buy list, the run times of the caller and the parts and draws
1104
+ * @throws RangeError for a device whose cells are not a resource of the catalog
1105
+ */
1106
+ export declare function deviceFragment(input: DeviceFragmentInput): DeviceFragmentResult;
1000
1107
  //# sourceMappingURL=index.d.ts.map
@@ -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","../src/mix.ts","../src/daily.ts"],"mappings":";;;;qBAQa;;YAGD,wBAAwB;;qBAGvB;;YAGD,qBAAqB;;;;;YAMrB;WAAyB,QAAQ,SAAS,OAAO,eAAe;WAAqB;;WAA4B,MAAM;WAAmB;;;iBAGrI;WACN,KAAK;;WAEL;;WAEA;;WAEA;WACA,MAAM;;;;;;iBAOA;;WAEN;;WAEA;;WAEA,KAAK;;WAEL,QAAQ;;WAER;;WAEA;;;iBAIM;;WAEN;WACA;WACA,QAAQ;;WAER;;WAEA,eAAe;;WAEf,mBAAmB;;;;;;YAOlB,gBAAgB,wBAAwB;;;;;;;;qBASvC;;YAGD,wBAAwB;;iBAGnB;WACN,KAAK;;WAEL;WACA;;WAEA,QAAQ;;WAER;;;;;WAKA,UAAU;;;YAIT;WACG,QAAQ;WAAiB;WAAqB,OAAO;WAAwB;WAAwB;WAAsB;WAAqC,MAAM;;WACtK,QAAQ;WAAiB;WAAsB;;;iBAG7C;;WAEN,gBAAgB;;WAEhB;;WAEA,MAAM;;WAEN;;;wBASK,gBAAgB,iBAAiB,SAAS;;;;;;;;wBAW1C,WAAW,OAAO,cAAc,KAAK,YAAY,oBAAoB;;;;;;;;;wBAYrE,aAAa,QAAQ,eAAe,KAAK,YAAY;WAA+B,OAAO;WAAuB,KAAK;;;;;;;;;wBAoBvH,cAAc,OAAO,cAAc,KAAK,YAAY,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;wBA4BpE,YAAY,QAAQ,e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A;WACA;aAA+B;aAAuB;;WACtD;WACA;WACA,qBAAqB;;;iBAIf;WACN;WACA;;;iBAIM;WACN,OAAO;;WAEP,gBAAgB;;WAEhB,kBAAkB;;WAElB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAsOK,aAAa,OAAO,oBAAoB;;;;;;;;;;;;;;;;;wBC9YxC,gBAAgB,yBAAyB,MAAK;;iBAS7C;;WAEN;;WAEA;;WAEA;;WAEA;;WAEA;;;;;;;;;;;wBAYK,gBAAgB,MAAK,kBAAgC;;iBASpD;;WAEN,SAAS;;WAET,OAAO,SAAS;;WAEhB,MAAM;;WAEN;;;iBAIM;WACN;;WAEA,QAAQ;;WAER,OAAO;;;iBAID;WACN;WACA;aAA2B;aAA2B;;WACtD;aAAkB;aAA2B;;;;iBAIvC;;WAEN;WACA;WACA;aAA+B;aAAuB;;WACtD;WACA;WACA,qBAAqB;;;iBAIf;WACN,OAAO;;WAEP,gBAAgB;;WAEhB;;WAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBA8DK,mBAAmB,OAAO,kBAAkB;;qBCtK/C;;qBAEA;;qBAEA;;YAGD;;iBAGK;WACN;;WAEA,QAAQ;WACR,kBAAkB;;WAElB;;;iBAIM;WACN;WACA;;;iBAIM;;WAEN;;WAEA;WACA,OAAO;WACP,MAAM,gBAAgB;;;qBAIpB,sBAAsB;;qBAWtB,mBAAmB;;;;;;;;;;qBAmBnB,sBAAsB;;;;;;;;;qBAiDtB;;YAGD,wBAAwB;;YAGxB,mBAAmB,QAAQ,gBAAgB;;;;;;;;;wBA4BvC,gBAAgB,gBAAgB,aAAa,UAAU,cAAc"}
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","../src/mix.ts","../src/daily.ts","../src/device.ts"],"mappings":";;;;qBAQa;;YAGD,wBAAwB;;qBAGvB;;YAGD,qBAAqB;;;;;Y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Food(catalog, code) {
1812
1812
  * 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.
1813
1813
  * A store of the resource from a different fragment gets the converter of this list.
1814
1814
  *
1815
- * The catalog of market gives no soak water. A food that needs a soak, for example dry beans, has a second water draw that this function does not give.
1815
+ * Market gives the soak water of a dry food with `soakWater`. This function does not take it. Thus the water of a food with a soak, for example dry beans, is a lower limit.
1816
1816
  * A product that gives more than one food has no energy for each food, so its energy is a no read.
1817
1817
  *
1818
1818
  * The cook water is `water.stored`, the store of the drinking water. A drinking draw at a higher level of the same store takes
@@ -2272,6 +2272,181 @@ function checkDailyNeeds(needs, options) {
2272
2272
  });
2273
2273
  return findings;
2274
2274
  }
2275
- export { ACTIVITY_LEVELS, ALERT_WATCH_NEED, BOIL_CELSIUS, BREAST_MILK_MONTHS, CALORIE_CHAIN, CALORIE_SEXES, CALORIE_TABLES, COLD_START_CELSIUS, DAILY_NEEDS, DAILY_NEED_CODES, DGA_CALORIES, DGA_SOURCE, DIRECT_USES, FDC_SR_LEGACY_SOURCE, FOOD_NEED, FORMULA_DRAW_MONTHS, FORMULA_FEEDS, FORMULA_LATER_LEAST, FORMULA_MIX, FORMULA_NEED, FORMULA_POWDER, FORMULA_READY, INFANT_FEEDINGS, INFANT_MONTHS, JOIN_CODES, LIGHT_NEED, MILK_LATER, NASEM_ENERGY_SOURCE, NASEM_INFANT_CALORIES, NEEDS_CODES, NEED_SUPPLIES, NIST_SI_GUIDE_SOURCE, NO_COOK, NWS_ALARMS_SOURCE, NWS_RECEIVERS_SOURCE, STORED_WATER, USGS_WATER_DENSITY_SOURCE, WARMTH_NEED, WATER_DENSITY_MAX, WATER_DENSITY_MIN, WATER_NEED, WATER_SPECIFIC_HEAT, WIC_INFANT_SOURCE, calorieChange, calorieNeed, calorieRow, calorieRowOf, checkCalorieChain, checkCalorieTable, checkDailyNeeds, checkJoins, cookFragment, formulaMixCheck, formulaMixFragment, formulaMixWater, hasNeedsError, householdFragment, isActivityLevel };
2275
+ // src/device.ts
2276
+ /** The hours in one day, from the definition of the day in `@mark1russell7/quantity`. */
2277
+ const HOURS_IN_DAY = valueIn({
2278
+ value: 1,
2279
+ unit: "d"
2280
+ }, "h");
2281
+ /** This function gives the value of an amount in a unit, or `undefined` when the units do not convert. */
2282
+ function amountIn(value, unit, to) {
2283
+ try {
2284
+ const out = valueIn({
2285
+ value,
2286
+ unit
2287
+ }, to);
2288
+ return Number.isFinite(out) ? out : void 0;
2289
+ } catch {
2290
+ return;
2291
+ }
2292
+ }
2293
+ /** This function gives the hours for each cell of a run time, or a no read with its reason. */
2294
+ function hoursOf(run, cell, where) {
2295
+ const hours = amountIn(run.amount, run.unit, "h");
2296
+ const cells = amountIn(run.per.amount, run.per.unit, cell);
2297
+ if (hours === void 0 || !(hours > 0)) return {
2298
+ read: false,
2299
+ why: `The run time ${run.amount} ${run.unit} of ${where} is not a time above 0.`
2300
+ };
2301
+ if (cells === void 0 || !(cells > 0)) return {
2302
+ read: false,
2303
+ why: `The run time of ${where} is on ${run.per.amount} ${run.per.unit}, and that is not a count of cells above 0 in ${cell}.`
2304
+ };
2305
+ return {
2306
+ read: true,
2307
+ value: hours / cells,
2308
+ unit: "h"
2309
+ };
2310
+ }
2311
+ /** This function gives the hours for each cell of a device: the input of the caller first, then the catalog. */
2312
+ function deviceHours(facts, run, cell, product) {
2313
+ if (run !== void 0) {
2314
+ if (run.cite.trim() === "") return {
2315
+ read: false,
2316
+ why: `The run time of the caller for ${product} has no citation.`
2317
+ };
2318
+ return hoursOf(run, cell, `the caller for ${product}`);
2319
+ }
2320
+ if (!("amount" in facts.run)) return {
2321
+ read: false,
2322
+ why: `The catalog gives no run time for ${product}: ${facts.run.why}`
2323
+ };
2324
+ return hoursOf(facts.run, cell, `the catalog for ${product}`);
2325
+ }
2326
+ /**
2327
+ * This function gives the device fragment of an endurance layer. Each device of the buy list with a cited run time gives
2328
+ * one converter. One run takes one cell and gives the hours of the need for each cell. The limit of runs for each day is
2329
+ * `HOURS_IN_DAY` divided by those hours. Thus one device gives 24 hours of its need in a day or less. The count of
2330
+ * devices is the count of whole units of the product. A device with no cited run time gives no converter, and a no read.
2331
+ *
2332
+ * With `draws`, each need of a device gives one draw. Its rate is the daily rate of the need in its unit for each day. The users are 1
2333
+ * for a need of the household. A need with no read of its rate gives no draw, and a no read.
2334
+ *
2335
+ * @param input - The catalog, the counts of the buy list, the run times of the caller and the parts and draws
2336
+ * @throws RangeError for a device whose cells are not a resource of the catalog
2337
+ */
2338
+ function deviceFragment(input) {
2339
+ const { catalog, units } = input;
2340
+ const prefix = input.prefix ?? "device";
2341
+ const unitOf = new Map(catalog.resources.map((resource) => [resource.code, resource.unit]));
2342
+ const lines = [];
2343
+ const noReads = [];
2344
+ const converters = [];
2345
+ const resources = [];
2346
+ const needs = [];
2347
+ const needList = input.needs ?? DAILY_NEEDS;
2348
+ for (const [id, count] of Object.entries(units)) {
2349
+ const facts = catalog.products.find((each) => each.id === id)?.device;
2350
+ if (facts === void 0 || !(count > 0)) continue;
2351
+ const cell = unitOf.get(facts.battery);
2352
+ if (cell === void 0) throw new RangeError(`The device ${id} runs on "${facts.battery}", and the catalog has no such resource.`);
2353
+ const devices = Math.floor(count);
2354
+ const hours = deviceHours(facts, input.runs?.[id], cell, id);
2355
+ lines.push({
2356
+ product: id,
2357
+ need: facts.need,
2358
+ battery: facts.battery,
2359
+ devices,
2360
+ hours
2361
+ });
2362
+ if (devices < 1) noReads.push({
2363
+ product: id,
2364
+ why: `The buy list has ${count} of ${id}, less than one whole device.`
2365
+ });
2366
+ else if (!hours.read) noReads.push({
2367
+ product: id,
2368
+ why: hours.why
2369
+ });
2370
+ else {
2371
+ const unit = needList.find((each) => each.code === facts.need)?.unit ?? "h";
2372
+ const gift = amountIn(hours.value, "h", unit);
2373
+ if (gift === void 0) {
2374
+ noReads.push({
2375
+ product: id,
2376
+ why: `The need ${facts.need} is in ${unit}, and that is not a time.`
2377
+ });
2378
+ if (!needs.includes(facts.need)) needs.push(facts.need);
2379
+ continue;
2380
+ }
2381
+ const part = input.parts?.[id];
2382
+ converters.push({
2383
+ id: `${prefix}:${id}`,
2384
+ ...part === void 0 ? {} : { device: part },
2385
+ takes: [{
2386
+ resource: facts.battery,
2387
+ amount: 1
2388
+ }],
2389
+ gives: {
2390
+ need: facts.need,
2391
+ amount: gift
2392
+ },
2393
+ perDay: HOURS_IN_DAY / hours.value,
2394
+ devices
2395
+ });
2396
+ if (!resources.some((each) => each.code === facts.battery)) resources.push({
2397
+ code: facts.battery,
2398
+ unit: cell
2399
+ });
2400
+ }
2401
+ if (!needs.includes(facts.need)) needs.push(facts.need);
2402
+ }
2403
+ const draws = [];
2404
+ if (input.draws !== void 0) {
2405
+ const { level, supply } = input.draws;
2406
+ for (const code of needs) {
2407
+ const need = needList.find((each) => each.code === code);
2408
+ if (need === void 0) noReads.push({
2409
+ need: code,
2410
+ why: `The daily needs have no need ${code}.`
2411
+ });
2412
+ else if (!need.rate.read) noReads.push({
2413
+ need: code,
2414
+ why: need.rate.why
2415
+ });
2416
+ else {
2417
+ const perDay = amountIn(need.rate.perDay.value, need.rate.perDay.unit, `${need.unit}/d`);
2418
+ if (perDay === void 0 || !(perDay > 0)) noReads.push({
2419
+ need: code,
2420
+ why: `The daily rate of ${code} is not an amount in ${need.unit} for each day above 0.`
2421
+ });
2422
+ else if (need.users !== "household") noReads.push({
2423
+ need: code,
2424
+ why: `The need ${code} is for each person. The device fragment has no count of persons.`
2425
+ });
2426
+ else draws.push({
2427
+ need: code,
2428
+ level,
2429
+ perDay,
2430
+ users: 1,
2431
+ supply
2432
+ });
2433
+ }
2434
+ }
2435
+ }
2436
+ return {
2437
+ layer: {
2438
+ schema: "endurance/1",
2439
+ levels: input.draws === void 0 ? [] : [input.draws.level],
2440
+ resources,
2441
+ stores: [],
2442
+ draws,
2443
+ converters
2444
+ },
2445
+ lines,
2446
+ noReads,
2447
+ read: noReads.length === 0
2448
+ };
2449
+ }
2450
+ export { ACTIVITY_LEVELS, ALERT_WATCH_NEED, BOIL_CELSIUS, BREAST_MILK_MONTHS, CALORIE_CHAIN, CALORIE_SEXES, CALORIE_TABLES, COLD_START_CELSIUS, DAILY_NEEDS, DAILY_NEED_CODES, DGA_CALORIES, DGA_SOURCE, DIRECT_USES, FDC_SR_LEGACY_SOURCE, FOOD_NEED, FORMULA_DRAW_MONTHS, FORMULA_FEEDS, FORMULA_LATER_LEAST, FORMULA_MIX, FORMULA_NEED, FORMULA_POWDER, FORMULA_READY, HOURS_IN_DAY, INFANT_FEEDINGS, INFANT_MONTHS, JOIN_CODES, LIGHT_NEED, MILK_LATER, NASEM_ENERGY_SOURCE, NASEM_INFANT_CALORIES, NEEDS_CODES, NEED_SUPPLIES, NIST_SI_GUIDE_SOURCE, NO_COOK, NWS_ALARMS_SOURCE, NWS_RECEIVERS_SOURCE, STORED_WATER, USGS_WATER_DENSITY_SOURCE, WARMTH_NEED, WATER_DENSITY_MAX, WATER_DENSITY_MIN, WATER_NEED, WATER_SPECIFIC_HEAT, WIC_INFANT_SOURCE, calorieChange, calorieNeed, calorieRow, calorieRowOf, checkCalorieChain, checkCalorieTable, checkDailyNeeds, checkJoins, cookFragment, deviceFragment, formulaMixCheck, formulaMixFragment, formulaMixWater, hasNeedsError, householdFragment, isActivityLevel };
2276
2451
 
2277
2452
  //# sourceMappingURL=index.js.map