formulab 0.5.1 → 0.10.1
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/CHANGELOG.md +126 -0
- package/README.md +122 -32
- package/dist/automotive/brakingDistance.d.ts +4 -0
- package/dist/automotive/brakingDistance.d.ts.map +1 -1
- package/dist/automotive/brakingDistance.js +8 -4
- package/dist/automotive/brakingDistance.js.map +1 -1
- package/dist/automotive/chargingLoss.d.ts +15 -0
- package/dist/automotive/chargingLoss.d.ts.map +1 -0
- package/dist/automotive/chargingLoss.js +62 -0
- package/dist/automotive/chargingLoss.js.map +1 -0
- package/dist/automotive/index.d.ts +2 -1
- package/dist/automotive/index.d.ts.map +1 -1
- package/dist/automotive/index.js +1 -0
- package/dist/automotive/index.js.map +1 -1
- package/dist/automotive/types.d.ts +23 -0
- package/dist/automotive/types.d.ts.map +1 -1
- package/dist/battery/cRate.d.ts.map +1 -1
- package/dist/battery/cRate.js +6 -0
- package/dist/battery/cRate.js.map +1 -1
- package/dist/battery/guards.d.ts +7 -0
- package/dist/battery/guards.d.ts.map +1 -0
- package/dist/battery/guards.js +17 -0
- package/dist/battery/guards.js.map +1 -0
- package/dist/battery/index.d.ts +1 -0
- package/dist/battery/index.d.ts.map +1 -1
- package/dist/battery/index.js +2 -0
- package/dist/battery/index.js.map +1 -1
- package/dist/chemical/dilution.js +4 -4
- package/dist/chemical/dilution.js.map +1 -1
- package/dist/chemical/flowControl.d.ts +14 -0
- package/dist/chemical/flowControl.d.ts.map +1 -0
- package/dist/chemical/flowControl.js +69 -0
- package/dist/chemical/flowControl.js.map +1 -0
- package/dist/chemical/guards.d.ts +17 -0
- package/dist/chemical/guards.d.ts.map +1 -0
- package/dist/chemical/guards.js +54 -0
- package/dist/chemical/guards.js.map +1 -0
- package/dist/chemical/heatTransfer.d.ts +6 -0
- package/dist/chemical/heatTransfer.d.ts.map +1 -1
- package/dist/chemical/heatTransfer.js +15 -9
- package/dist/chemical/heatTransfer.js.map +1 -1
- package/dist/chemical/index.d.ts +5 -1
- package/dist/chemical/index.d.ts.map +1 -1
- package/dist/chemical/index.js +5 -0
- package/dist/chemical/index.js.map +1 -1
- package/dist/chemical/pid.d.ts +14 -0
- package/dist/chemical/pid.d.ts.map +1 -0
- package/dist/chemical/pid.js +103 -0
- package/dist/chemical/pid.js.map +1 -0
- package/dist/chemical/pipeFlow.d.ts +6 -0
- package/dist/chemical/pipeFlow.d.ts.map +1 -1
- package/dist/chemical/pipeFlow.js +12 -6
- package/dist/chemical/pipeFlow.js.map +1 -1
- package/dist/chemical/reliefValve.d.ts +14 -0
- package/dist/chemical/reliefValve.d.ts.map +1 -0
- package/dist/chemical/reliefValve.js +98 -0
- package/dist/chemical/reliefValve.js.map +1 -0
- package/dist/chemical/types.d.ts +63 -0
- package/dist/chemical/types.d.ts.map +1 -1
- package/dist/construction/aggregate.d.ts +4 -0
- package/dist/construction/aggregate.d.ts.map +1 -1
- package/dist/construction/aggregate.js +8 -4
- package/dist/construction/aggregate.js.map +1 -1
- package/dist/construction/guards.d.ts +7 -0
- package/dist/construction/guards.d.ts.map +1 -0
- package/dist/construction/guards.js +31 -0
- package/dist/construction/guards.js.map +1 -0
- package/dist/construction/index.d.ts +1 -0
- package/dist/construction/index.d.ts.map +1 -1
- package/dist/construction/index.js +2 -0
- package/dist/construction/index.js.map +1 -1
- package/dist/construction/momentOfInertia.d.ts +7 -0
- package/dist/construction/momentOfInertia.d.ts.map +1 -1
- package/dist/construction/momentOfInertia.js +19 -12
- package/dist/construction/momentOfInertia.js.map +1 -1
- package/dist/construction/roof.js +2 -2
- package/dist/construction/roof.js.map +1 -1
- package/dist/electronics/awg.d.ts +3 -2
- package/dist/electronics/awg.d.ts.map +1 -1
- package/dist/electronics/awg.js +3 -3
- package/dist/electronics/awg.js.map +1 -1
- package/dist/electronics/capacitor.js +1 -1
- package/dist/electronics/capacitor.js.map +1 -1
- package/dist/electronics/guards.d.ts +7 -0
- package/dist/electronics/guards.d.ts.map +1 -0
- package/dist/electronics/guards.js +17 -0
- package/dist/electronics/guards.js.map +1 -0
- package/dist/electronics/index.d.ts +1 -0
- package/dist/electronics/index.d.ts.map +1 -1
- package/dist/electronics/index.js +2 -0
- package/dist/electronics/index.js.map +1 -1
- package/dist/electronics/led.js +2 -2
- package/dist/electronics/led.js.map +1 -1
- package/dist/electronics/ohmsLaw.d.ts +3 -0
- package/dist/electronics/ohmsLaw.d.ts.map +1 -1
- package/dist/electronics/ohmsLaw.js +11 -8
- package/dist/electronics/ohmsLaw.js.map +1 -1
- package/dist/electronics/stencil.d.ts +2 -1
- package/dist/electronics/stencil.d.ts.map +1 -1
- package/dist/electronics/stencil.js +4 -3
- package/dist/electronics/stencil.js.map +1 -1
- package/dist/energy/boilerEfficiency.d.ts +13 -0
- package/dist/energy/boilerEfficiency.d.ts.map +1 -0
- package/dist/energy/boilerEfficiency.js +46 -0
- package/dist/energy/boilerEfficiency.js.map +1 -0
- package/dist/energy/cusum.d.ts +15 -0
- package/dist/energy/cusum.d.ts.map +1 -0
- package/dist/energy/cusum.js +71 -0
- package/dist/energy/cusum.js.map +1 -0
- package/dist/energy/degreeDay.d.ts +13 -0
- package/dist/energy/degreeDay.d.ts.map +1 -0
- package/dist/energy/degreeDay.js +46 -0
- package/dist/energy/degreeDay.js.map +1 -0
- package/dist/energy/heatPump.d.ts +13 -0
- package/dist/energy/heatPump.d.ts.map +1 -0
- package/dist/energy/heatPump.js +48 -0
- package/dist/energy/heatPump.js.map +1 -0
- package/dist/energy/index.d.ts +9 -1
- package/dist/energy/index.d.ts.map +1 -1
- package/dist/energy/index.js +8 -0
- package/dist/energy/index.js.map +1 -1
- package/dist/energy/insulationRoi.d.ts +14 -0
- package/dist/energy/insulationRoi.d.ts.map +1 -0
- package/dist/energy/insulationRoi.js +52 -0
- package/dist/energy/insulationRoi.js.map +1 -0
- package/dist/energy/ledRoi.d.ts +14 -0
- package/dist/energy/ledRoi.d.ts.map +1 -0
- package/dist/energy/ledRoi.js +49 -0
- package/dist/energy/ledRoi.js.map +1 -0
- package/dist/energy/solarOutput.d.ts +4 -0
- package/dist/energy/solarOutput.d.ts.map +1 -1
- package/dist/energy/solarOutput.js +8 -4
- package/dist/energy/solarOutput.js.map +1 -1
- package/dist/energy/transformerLoss.d.ts +13 -0
- package/dist/energy/transformerLoss.d.ts.map +1 -0
- package/dist/energy/transformerLoss.js +63 -0
- package/dist/energy/transformerLoss.js.map +1 -0
- package/dist/energy/types.d.ts +168 -0
- package/dist/energy/types.d.ts.map +1 -1
- package/dist/energy/windOutput.d.ts +14 -0
- package/dist/energy/windOutput.d.ts.map +1 -0
- package/dist/energy/windOutput.js +77 -0
- package/dist/energy/windOutput.js.map +1 -0
- package/dist/environmental/scope2Emissions.d.ts +1 -0
- package/dist/environmental/scope2Emissions.d.ts.map +1 -1
- package/dist/environmental/scope2Emissions.js +2 -1
- package/dist/environmental/scope2Emissions.js.map +1 -1
- package/dist/food/index.d.ts +3 -1
- package/dist/food/index.d.ts.map +1 -1
- package/dist/food/index.js +2 -0
- package/dist/food/index.js.map +1 -1
- package/dist/food/stabilityStudy.d.ts +15 -0
- package/dist/food/stabilityStudy.d.ts.map +1 -0
- package/dist/food/stabilityStudy.js +92 -0
- package/dist/food/stabilityStudy.js.map +1 -0
- package/dist/food/types.d.ts +43 -0
- package/dist/food/types.d.ts.map +1 -1
- package/dist/food/waterActivity.d.ts +17 -0
- package/dist/food/waterActivity.d.ts.map +1 -0
- package/dist/food/waterActivity.js +63 -0
- package/dist/food/waterActivity.js.map +1 -0
- package/dist/logistics/abcAnalysis.d.ts +15 -0
- package/dist/logistics/abcAnalysis.d.ts.map +1 -0
- package/dist/logistics/abcAnalysis.js +101 -0
- package/dist/logistics/abcAnalysis.js.map +1 -0
- package/dist/logistics/index.d.ts +4 -1
- package/dist/logistics/index.d.ts.map +1 -1
- package/dist/logistics/index.js +3 -0
- package/dist/logistics/index.js.map +1 -1
- package/dist/logistics/inventoryTurnover.d.ts +13 -0
- package/dist/logistics/inventoryTurnover.d.ts.map +1 -0
- package/dist/logistics/inventoryTurnover.js +36 -0
- package/dist/logistics/inventoryTurnover.js.map +1 -0
- package/dist/logistics/loadCapacity.d.ts +13 -0
- package/dist/logistics/loadCapacity.d.ts.map +1 -0
- package/dist/logistics/loadCapacity.js +46 -0
- package/dist/logistics/loadCapacity.js.map +1 -0
- package/dist/logistics/types.d.ts +78 -0
- package/dist/logistics/types.d.ts.map +1 -1
- package/dist/machining/boringBarDeflection.d.ts.map +1 -1
- package/dist/machining/boringBarDeflection.js +7 -1
- package/dist/machining/boringBarDeflection.js.map +1 -1
- package/dist/machining/toolDeflection.d.ts.map +1 -1
- package/dist/machining/toolDeflection.js +7 -1
- package/dist/machining/toolDeflection.js.map +1 -1
- package/dist/machining/triangleSolver.d.ts +2 -1
- package/dist/machining/triangleSolver.d.ts.map +1 -1
- package/dist/machining/triangleSolver.js +6 -5
- package/dist/machining/triangleSolver.js.map +1 -1
- package/dist/metal/flangeSpec.d.ts +3 -0
- package/dist/metal/flangeSpec.d.ts.map +1 -1
- package/dist/metal/flangeSpec.js +6 -3
- package/dist/metal/flangeSpec.js.map +1 -1
- package/dist/metal/guards.d.ts +12 -0
- package/dist/metal/guards.d.ts.map +1 -0
- package/dist/metal/guards.js +36 -0
- package/dist/metal/guards.js.map +1 -0
- package/dist/metal/index.d.ts +1 -0
- package/dist/metal/index.d.ts.map +1 -1
- package/dist/metal/index.js +2 -0
- package/dist/metal/index.js.map +1 -1
- package/dist/metal/metalWeight.d.ts.map +1 -1
- package/dist/metal/metalWeight.js +20 -0
- package/dist/metal/metalWeight.js.map +1 -1
- package/dist/metal/pipeSpec.d.ts +3 -0
- package/dist/metal/pipeSpec.d.ts.map +1 -1
- package/dist/metal/pipeSpec.js +6 -3
- package/dist/metal/pipeSpec.js.map +1 -1
- package/dist/quality/cmk.d.ts +17 -0
- package/dist/quality/cmk.d.ts.map +1 -0
- package/dist/quality/cmk.js +43 -0
- package/dist/quality/cmk.js.map +1 -0
- package/dist/quality/controlChart.d.ts +3 -0
- package/dist/quality/controlChart.d.ts.map +1 -1
- package/dist/quality/controlChart.js +6 -3
- package/dist/quality/controlChart.js.map +1 -1
- package/dist/quality/gageRR.d.ts +18 -0
- package/dist/quality/gageRR.d.ts.map +1 -0
- package/dist/quality/gageRR.js +110 -0
- package/dist/quality/gageRR.js.map +1 -0
- package/dist/quality/index.d.ts +5 -1
- package/dist/quality/index.d.ts.map +1 -1
- package/dist/quality/index.js +4 -0
- package/dist/quality/index.js.map +1 -1
- package/dist/quality/oee.js +2 -2
- package/dist/quality/oee.js.map +1 -1
- package/dist/quality/paretoAnalysis.d.ts +15 -0
- package/dist/quality/paretoAnalysis.d.ts.map +1 -0
- package/dist/quality/paretoAnalysis.js +92 -0
- package/dist/quality/paretoAnalysis.js.map +1 -0
- package/dist/quality/types.d.ts +91 -0
- package/dist/quality/types.d.ts.map +1 -1
- package/dist/quality/weibull.d.ts +17 -0
- package/dist/quality/weibull.d.ts.map +1 -0
- package/dist/quality/weibull.js +106 -0
- package/dist/quality/weibull.js.map +1 -0
- package/dist/safety/arcFlash.d.ts +14 -0
- package/dist/safety/arcFlash.d.ts.map +1 -0
- package/dist/safety/arcFlash.js +90 -0
- package/dist/safety/arcFlash.js.map +1 -0
- package/dist/safety/confinedSpace.d.ts +15 -0
- package/dist/safety/confinedSpace.d.ts.map +1 -0
- package/dist/safety/confinedSpace.js +116 -0
- package/dist/safety/confinedSpace.js.map +1 -0
- package/dist/safety/ergonomicRisk.d.ts +9 -0
- package/dist/safety/ergonomicRisk.d.ts.map +1 -0
- package/dist/safety/ergonomicRisk.js +208 -0
- package/dist/safety/ergonomicRisk.js.map +1 -0
- package/dist/safety/illuminance.d.ts +13 -0
- package/dist/safety/illuminance.d.ts.map +1 -0
- package/dist/safety/illuminance.js +91 -0
- package/dist/safety/illuminance.js.map +1 -0
- package/dist/safety/index.d.ts +8 -1
- package/dist/safety/index.d.ts.map +1 -1
- package/dist/safety/index.js +7 -0
- package/dist/safety/index.js.map +1 -1
- package/dist/safety/ladderAngle.d.ts +16 -0
- package/dist/safety/ladderAngle.d.ts.map +1 -0
- package/dist/safety/ladderAngle.js +87 -0
- package/dist/safety/ladderAngle.js.map +1 -0
- package/dist/safety/lel.d.ts +14 -0
- package/dist/safety/lel.d.ts.map +1 -0
- package/dist/safety/lel.js +66 -0
- package/dist/safety/lel.js.map +1 -0
- package/dist/safety/thermalComfort.d.ts +14 -0
- package/dist/safety/thermalComfort.d.ts.map +1 -0
- package/dist/safety/thermalComfort.js +96 -0
- package/dist/safety/thermalComfort.js.map +1 -0
- package/dist/safety/types.d.ts +164 -0
- package/dist/safety/types.d.ts.map +1 -1
- package/dist/safety/ventilationRate.d.ts +3 -0
- package/dist/safety/ventilationRate.d.ts.map +1 -1
- package/dist/safety/ventilationRate.js +6 -3
- package/dist/safety/ventilationRate.js.map +1 -1
- package/dist/utility/bilinearInterpolation.d.ts +3 -0
- package/dist/utility/bilinearInterpolation.d.ts.map +1 -0
- package/dist/utility/bilinearInterpolation.js +47 -0
- package/dist/utility/bilinearInterpolation.js.map +1 -0
- package/dist/utility/correlation.d.ts +3 -0
- package/dist/utility/correlation.d.ts.map +1 -0
- package/dist/utility/correlation.js +29 -0
- package/dist/utility/correlation.js.map +1 -0
- package/dist/utility/depreciation.d.ts +3 -0
- package/dist/utility/depreciation.d.ts.map +1 -0
- package/dist/utility/depreciation.js +57 -0
- package/dist/utility/depreciation.js.map +1 -0
- package/dist/utility/histogram.d.ts +3 -0
- package/dist/utility/histogram.d.ts.map +1 -0
- package/dist/utility/histogram.js +42 -0
- package/dist/utility/histogram.js.map +1 -0
- package/dist/utility/index.d.ts +15 -1
- package/dist/utility/index.d.ts.map +1 -1
- package/dist/utility/index.js +14 -0
- package/dist/utility/index.js.map +1 -1
- package/dist/utility/lcc.d.ts +3 -0
- package/dist/utility/lcc.d.ts.map +1 -0
- package/dist/utility/lcc.js +26 -0
- package/dist/utility/lcc.js.map +1 -0
- package/dist/utility/linearInterpolation.d.ts +3 -0
- package/dist/utility/linearInterpolation.d.ts.map +1 -0
- package/dist/utility/linearInterpolation.js +42 -0
- package/dist/utility/linearInterpolation.js.map +1 -0
- package/dist/utility/movingAverage.d.ts +3 -0
- package/dist/utility/movingAverage.d.ts.map +1 -0
- package/dist/utility/movingAverage.js +41 -0
- package/dist/utility/movingAverage.js.map +1 -0
- package/dist/utility/normalize.d.ts +3 -0
- package/dist/utility/normalize.d.ts.map +1 -0
- package/dist/utility/normalize.js +35 -0
- package/dist/utility/normalize.js.map +1 -0
- package/dist/utility/npv.d.ts +3 -0
- package/dist/utility/npv.d.ts.map +1 -0
- package/dist/utility/npv.js +45 -0
- package/dist/utility/npv.js.map +1 -0
- package/dist/utility/percentile.d.ts +3 -0
- package/dist/utility/percentile.d.ts.map +1 -0
- package/dist/utility/percentile.js +24 -0
- package/dist/utility/percentile.js.map +1 -0
- package/dist/utility/regression.d.ts +3 -0
- package/dist/utility/regression.d.ts.map +1 -0
- package/dist/utility/regression.js +40 -0
- package/dist/utility/regression.js.map +1 -0
- package/dist/utility/roi.d.ts +3 -0
- package/dist/utility/roi.d.ts.map +1 -0
- package/dist/utility/roi.js +19 -0
- package/dist/utility/roi.js.map +1 -0
- package/dist/utility/statistics.d.ts +3 -0
- package/dist/utility/statistics.d.ts.map +1 -0
- package/dist/utility/statistics.js +34 -0
- package/dist/utility/statistics.js.map +1 -0
- package/dist/utility/types.d.ts +213 -1
- package/dist/utility/types.d.ts.map +1 -1
- package/dist/utility/unit.d.ts.map +1 -1
- package/dist/utility/unit.js +51 -0
- package/dist/utility/unit.js.map +1 -1
- package/dist/utility/weightedScore.d.ts +3 -0
- package/dist/utility/weightedScore.d.ts.map +1 -0
- package/dist/utility/weightedScore.js +35 -0
- package/dist/utility/weightedScore.js.map +1 -0
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,132 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [0.10.1] - 2026-02-09
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- **`throw new Error` → `throw new RangeError`** across all 18 remaining files — runtime error type now matches `@throws {RangeError}` JSDoc and ERRORS.md policy. Affected domains: automotive, chemical, construction, electronics, energy, environmental, machining, metal, quality, safety.
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
|
|
16
|
+
- **README.md** — Updated test count (2,494), error handling section (no legacy NaN/Infinity), utility domain (3 → 16 functions).
|
|
17
|
+
|
|
18
|
+
## [0.10.0] - 2026-02-09
|
|
19
|
+
|
|
20
|
+
### Breaking Changes
|
|
21
|
+
|
|
22
|
+
- **`awgProperties()` return type** — Changed from `AwgResult | null` to `AwgResult`. Invalid AWG range (< 0 or > 40) now throws `RangeError` instead of returning `null`.
|
|
23
|
+
- **`metalWeight()`** — Now throws `RangeError` on non-positive dimensions (length, width, thickness, diameter) and when outerDiameter ≤ innerDiameter for pipes.
|
|
24
|
+
- **`cRate()`** — Now throws `RangeError` when capacityAh ≤ 0, currentA ≤ 0, or cRate ≤ 0. Previously returned `Infinity`.
|
|
25
|
+
- **`toolDeflection()`** — Now throws `RangeError` on non-positive toolDiameter/stickout or negative cuttingForce. Stiffness is computed as `3EI/L³` (beam property) instead of `F/δ`.
|
|
26
|
+
- **`boringBarDeflection()`** — Same changes as `toolDeflection()`: validation + stiffness formula fix.
|
|
27
|
+
- **`heatTransfer()`** — All `throw new Error()` changed to `throw new RangeError()`. Removed `Infinity` fallback in radiation thermal resistance.
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
|
|
31
|
+
- **`@throws` JSDoc annotations** for 14 functions across 10 domains — documents every throw condition for IDE/editor hints:
|
|
32
|
+
- automotive: `brakingDistance`
|
|
33
|
+
- chemical: `heatTransfer`, `pipeFlow`
|
|
34
|
+
- construction: `aggregate`, `momentOfInertia`
|
|
35
|
+
- electronics: `ohmsLaw`, `stencil`
|
|
36
|
+
- energy: `solarOutput`
|
|
37
|
+
- environmental: `scope2Emissions`
|
|
38
|
+
- machining: `triangleSolver`
|
|
39
|
+
- metal: `flangeSpec`, `pipeSpec`
|
|
40
|
+
- quality: `controlChart`
|
|
41
|
+
- safety: `ventilationRate`
|
|
42
|
+
|
|
43
|
+
- **26 new validation tests** — error path coverage for `metalWeight`, `cRate`, `toolDeflection`, `boringBarDeflection`, `heatTransfer`, `awgProperties`
|
|
44
|
+
|
|
45
|
+
### Changed
|
|
46
|
+
|
|
47
|
+
- **ERRORS.md** — Removed legacy migration roadmap (all NaN/Infinity patterns resolved). Updated all 6 function entries to reflect `throw` behavior.
|
|
48
|
+
- Total test count: 2468 → 2494 (+26)
|
|
49
|
+
|
|
50
|
+
## [0.9.0] - 2026-02-09
|
|
51
|
+
|
|
52
|
+
### Added
|
|
53
|
+
|
|
54
|
+
- **Type Guards** — 8 runtime type guard functions for discriminated union inputs ([#2](https://github.com/iyulab/formulab/issues/2)):
|
|
55
|
+
- `isCRateInput()` — battery domain (mode: currentToRate | rateToCurrent)
|
|
56
|
+
- `isDilutionInput()` — chemical domain (solveFor: c1 | v1 | c2 | v2)
|
|
57
|
+
- `isReactorInput()` — chemical domain (shape: cylindrical | spherical)
|
|
58
|
+
- `isHeatTransferInput()` — chemical domain (mode: conduction | convection | radiation)
|
|
59
|
+
- `isMomentOfInertiaInput()` — construction domain (shape: 7 variants)
|
|
60
|
+
- `isOhmsLawInput()` — electronics domain (solveFor: voltage | current | resistance | power)
|
|
61
|
+
- `isMetalWeightInput()` — metal domain (shape: plate | round | pipe | angle)
|
|
62
|
+
- `isBoltInput()` — metal domain (mode: torqueToPreload | preloadToTorque)
|
|
63
|
+
|
|
64
|
+
- **Error Behavior Specification** — `ERRORS.md` documenting error policy and per-function error behavior ([#1](https://github.com/iyulab/formulab/issues/1)):
|
|
65
|
+
- Defined error policy: validation failures → throw RangeError
|
|
66
|
+
- Documented all 174 functions' error behavior (throw / NaN / Infinity / null / safe)
|
|
67
|
+
- Identified 6 legacy NaN/Infinity patterns with migration roadmap to v0.10.0
|
|
68
|
+
|
|
69
|
+
### Changed
|
|
70
|
+
|
|
71
|
+
- Total function count: 174 → 182 (+8 type guards)
|
|
72
|
+
|
|
73
|
+
## [0.7.0] - 2026-02-07
|
|
74
|
+
|
|
75
|
+
### Added
|
|
76
|
+
|
|
77
|
+
- **Quality** (+4 functions, 14 → 18):
|
|
78
|
+
- `gageRR()` — Gage R&R repeatability/reproducibility analysis (AIAG MSA 4th Edition)
|
|
79
|
+
- `cmk()` — Machine capability index Cm/Cmk (threshold ≥ 1.67)
|
|
80
|
+
- `weibull()` — Weibull reliability analysis with median rank regression
|
|
81
|
+
- `paretoAnalysis()` — Pareto 80/20 ABC classification
|
|
82
|
+
|
|
83
|
+
- **Safety** (+5 functions, 9 → 14):
|
|
84
|
+
- `thermalComfort()` — PMV/PPD thermal comfort (ISO 7730 Fanger model)
|
|
85
|
+
- `ergonomicRisk()` — REBA ergonomic risk assessment scoring
|
|
86
|
+
- `arcFlash()` — Arc flash incident energy & PPE category (IEEE 1584/NFPA 70E)
|
|
87
|
+
- `confinedSpace()` — Confined space atmospheric assessment (OSHA 29 CFR 1910.146)
|
|
88
|
+
- `lel()` — Lower explosive limit for mixed gases (Le Chatelier's rule)
|
|
89
|
+
|
|
90
|
+
- **Energy** (+4 functions, 11 → 15):
|
|
91
|
+
- `heatPump()` — Heat pump COP & Carnot efficiency with annual savings
|
|
92
|
+
- `degreeDay()` — Heating/Cooling degree day calculation (HDD/CDD)
|
|
93
|
+
- `windOutput()` — Wind turbine output with Rayleigh capacity factor
|
|
94
|
+
- `cusum()` — CUSUM energy anomaly detection (Page's algorithm)
|
|
95
|
+
|
|
96
|
+
- **Chemical** (+3 functions, 9 → 12):
|
|
97
|
+
- `flowControl()` — Control valve Cv/Kv sizing (ISA/IEC 60534)
|
|
98
|
+
- `reliefValve()` — Safety relief valve sizing (API 520/526)
|
|
99
|
+
- `pid()` — PID controller tuning (Ziegler-Nichols / Cohen-Coon)
|
|
100
|
+
|
|
101
|
+
- **Logistics** (+1 function, 16 → 17):
|
|
102
|
+
- `abcAnalysis()` — ABC inventory classification by annual value
|
|
103
|
+
|
|
104
|
+
- **Food** (+2 functions, 4 → 6):
|
|
105
|
+
- `waterActivity()` — Water activity microbial growth risk (HACCP)
|
|
106
|
+
- `stabilityStudy()` — Accelerated stability study with Arrhenius regression (ICH Q1A)
|
|
107
|
+
|
|
108
|
+
- **Automotive** (+1 function, 8 → 9):
|
|
109
|
+
- `chargingLoss()` — EV charging loss/efficiency with temperature derating
|
|
110
|
+
|
|
111
|
+
### Changed
|
|
112
|
+
|
|
113
|
+
- Total function count: 154 → 174 (+20)
|
|
114
|
+
- Total domains: 14 (unchanged)
|
|
115
|
+
|
|
116
|
+
## [0.6.0] - 2026-02-07
|
|
117
|
+
|
|
118
|
+
### Added
|
|
119
|
+
|
|
120
|
+
- **Energy** (+4 functions, 7 → 11):
|
|
121
|
+
- `boilerEfficiency()` — Boiler thermal efficiency (direct input-output method)
|
|
122
|
+
- `transformerLoss()` — Transformer loss calculation with optimal load point
|
|
123
|
+
- `insulationRoi()` — Insulation ROI with payback period
|
|
124
|
+
- `ledRoi()` — LED lighting retrofit ROI with CO2 savings
|
|
125
|
+
|
|
126
|
+
- **Safety** (+2 functions, 7 → 9):
|
|
127
|
+
- `ladderAngle()` — Ladder safety angle calculation (OSHA 4:1 rule, 70°–80° compliance)
|
|
128
|
+
- `illuminance()` — Workplace illuminance calculation (Lumen Method with CU lookup)
|
|
129
|
+
|
|
130
|
+
- **Logistics** (+2 functions, 14 → 16):
|
|
131
|
+
- `inventoryTurnover()` — Inventory turnover ratio, days/weeks of supply, GMROII
|
|
132
|
+
- `loadCapacity()` — Forklift load capacity derating with attachment loss
|
|
133
|
+
|
|
8
134
|
## [0.5.0] - 2026-02-07
|
|
9
135
|
|
|
10
136
|
### Added
|
package/README.md
CHANGED
|
@@ -11,29 +11,29 @@ A comprehensive collection of engineering formulas and calculations for manufact
|
|
|
11
11
|
|
|
12
12
|
## Features
|
|
13
13
|
|
|
14
|
-
- **
|
|
14
|
+
- **174 industrial calculations + 8 type guards** — OEE, Cpk, SPC control charts, Gage R&R, Weibull, metal weight, CNC machining, GD&T, pipe flow, CBM, NIOSH lifting, PMV/PPD, arc flash, battery SOH, GHG emissions, PID tuning, and more
|
|
15
15
|
- **14 specialized domains** — Quality, Metal, Chemical, Electronics, Construction, Automotive, Logistics, Energy, Safety, Food, Utility, Battery, Environmental, Machining
|
|
16
16
|
- **Zero dependencies** — Lightweight and fast
|
|
17
17
|
- **TypeScript first** — Full type definitions included
|
|
18
18
|
- **Tree-shakeable** — Import only what you need
|
|
19
|
-
- **
|
|
19
|
+
- **2,494 tests** — Coverage thresholds: 90% lines, 95% functions, 85% branches ([CI pipeline](https://github.com/iyulab/formulab/actions/workflows/ci.yml))
|
|
20
20
|
- **Research-based** — Golden reference tests verified against NIOSH 94-110, AIAG/ASTM E2587, JIPM, ASME B16.5, ISO 22514-2, and more
|
|
21
21
|
|
|
22
22
|
## Verification Status
|
|
23
23
|
|
|
24
24
|
| Domain | Functions | Golden Tests | Key References |
|
|
25
25
|
|--------|-----------|-------------|----------------|
|
|
26
|
-
| Quality |
|
|
26
|
+
| Quality | 18 | oee, cpk, controlChart, gageRR | ISO 22400-2, AIAG/ASTM E2587, JIPM, AIAG MSA |
|
|
27
27
|
| Metal | 25 | metalWeight | Machinery's Handbook, ASME B36.10/B16.5 |
|
|
28
|
-
| Logistics |
|
|
29
|
-
| Safety |
|
|
30
|
-
| Chemical |
|
|
28
|
+
| Logistics | 17 | cbm | Physical formula |
|
|
29
|
+
| Safety | 14 | nioshLifting | NIOSH 94-110, ISO 7730, IEEE 1584, OSHA |
|
|
30
|
+
| Chemical | 12 | — | Darcy-Weisbach, Fourier, API 520, ISA |
|
|
31
31
|
| Electronics | 11 | — | IPC-2221 |
|
|
32
32
|
| Construction | 12 | — | AISC, Timoshenko |
|
|
33
|
-
| Automotive |
|
|
34
|
-
| Energy |
|
|
35
|
-
| Food |
|
|
36
|
-
| Utility |
|
|
33
|
+
| Automotive | 9 | — | AASHTO, SAE J1772 |
|
|
34
|
+
| Energy | 15 | — | NREL PVWatts, ISO 50001 |
|
|
35
|
+
| Food | 6 | — | HACCP, ICH Q1A |
|
|
36
|
+
| Utility | 16 | — | — |
|
|
37
37
|
| Battery | 10 | — | IEEE 1188, IEC 62620, Battery University |
|
|
38
38
|
| Environmental | 10 | — | GHG Protocol, IPCC AR6, IEA 2023 |
|
|
39
39
|
| Machining | 12 | — | Machinery's Handbook, ASME Y14.5, Sandvik Coromant |
|
|
@@ -52,7 +52,7 @@ roundTo(0.615, 2) // → 0.62 (not 0.61)
|
|
|
52
52
|
roundTo(-2.555, 2) // → -2.56 (sign-aware)
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
Non-finite values (`NaN`, `Infinity`) pass through unchanged. Each function's JSDoc specifies output precision (typically 2-4 decimal places).
|
|
55
|
+
Non-finite values (`NaN`, `Infinity`) pass through unchanged. All validation errors throw `RangeError` — no function returns NaN or Infinity for invalid inputs. Each function's JSDoc specifies output precision (typically 2-4 decimal places) and `@throws` conditions.
|
|
56
56
|
|
|
57
57
|
### Golden Reference Tests
|
|
58
58
|
|
|
@@ -157,10 +157,10 @@ console.log(volume.totalCbm); // 0.96 m³
|
|
|
157
157
|
|
|
158
158
|
## Domains
|
|
159
159
|
|
|
160
|
-
### Quality & Production (
|
|
160
|
+
### Quality & Production (18 functions)
|
|
161
161
|
|
|
162
162
|
```typescript
|
|
163
|
-
import { oee, cpk, taktTime, dpmo, controlChart } from 'formulab/quality';
|
|
163
|
+
import { oee, cpk, taktTime, dpmo, controlChart, gageRR, weibull } from 'formulab/quality';
|
|
164
164
|
```
|
|
165
165
|
|
|
166
166
|
| Function | Description |
|
|
@@ -179,6 +179,10 @@ import { oee, cpk, taktTime, dpmo, controlChart } from 'formulab/quality';
|
|
|
179
179
|
| `ppm()` | Parts Per Million conversion |
|
|
180
180
|
| `rpn()` | Risk Priority Number (FMEA) |
|
|
181
181
|
| `yieldCalc()` | First Pass Yield / RTY |
|
|
182
|
+
| `gageRR()` | Gage R&R (AIAG MSA Average & Range) |
|
|
183
|
+
| `cmk()` | Machine capability index Cm/Cmk |
|
|
184
|
+
| `weibull()` | Weibull reliability analysis |
|
|
185
|
+
| `paretoAnalysis()` | Pareto 80/20 ABC classification |
|
|
182
186
|
|
|
183
187
|
### Metal & Machining (25 functions)
|
|
184
188
|
|
|
@@ -214,10 +218,10 @@ import { metalWeight, bendAllowance, cutting, bearing } from 'formulab/metal';
|
|
|
214
218
|
| `pipeSpec()` | ANSI/ASME pipe dimensions lookup |
|
|
215
219
|
| `flangeSpec()` | ASME B16.5 flange dimensions lookup |
|
|
216
220
|
|
|
217
|
-
### Chemical & Process (
|
|
221
|
+
### Chemical & Process (12 functions)
|
|
218
222
|
|
|
219
223
|
```typescript
|
|
220
|
-
import { dilution, concentration, ph, reactor, pipeFlow, heatTransfer } from 'formulab/chemical';
|
|
224
|
+
import { dilution, concentration, ph, reactor, pipeFlow, heatTransfer, flowControl, pid } from 'formulab/chemical';
|
|
221
225
|
```
|
|
222
226
|
|
|
223
227
|
| Function | Description |
|
|
@@ -231,6 +235,9 @@ import { dilution, concentration, ph, reactor, pipeFlow, heatTransfer } from 'fo
|
|
|
231
235
|
| `reactor()` | Reactor sizing |
|
|
232
236
|
| `shelfLife()` | Shelf life prediction (Arrhenius) |
|
|
233
237
|
| `injectionCycle()` | Injection molding cycle time |
|
|
238
|
+
| `flowControl()` | Control valve Cv/Kv sizing (ISA/IEC 60534) |
|
|
239
|
+
| `reliefValve()` | Safety relief valve sizing (API 520/526) |
|
|
240
|
+
| `pid()` | PID controller tuning (Z-N / Cohen-Coon) |
|
|
234
241
|
|
|
235
242
|
### Electronics & SMT (11 functions)
|
|
236
243
|
|
|
@@ -273,10 +280,10 @@ import { concreteMix, rebarWeight, slope, stair, momentOfInertia } from 'formula
|
|
|
273
280
|
| `roof()` | Roof calculation |
|
|
274
281
|
| `stair()` | Stair dimension calculation |
|
|
275
282
|
|
|
276
|
-
### Automotive (
|
|
283
|
+
### Automotive (9 functions)
|
|
277
284
|
|
|
278
285
|
```typescript
|
|
279
|
-
import { batteryRuntime, evCharging, torque, brakingDistance } from 'formulab/automotive';
|
|
286
|
+
import { batteryRuntime, evCharging, torque, brakingDistance, chargingLoss } from 'formulab/automotive';
|
|
280
287
|
```
|
|
281
288
|
|
|
282
289
|
| Function | Description |
|
|
@@ -289,22 +296,26 @@ import { batteryRuntime, evCharging, torque, brakingDistance } from 'formulab/au
|
|
|
289
296
|
| `tireCompare()` | Tire size comparison |
|
|
290
297
|
| `torque()` | Torque conversion |
|
|
291
298
|
| `power()` | Power conversion (HP, kW) |
|
|
299
|
+
| `chargingLoss()` | EV charging loss/efficiency |
|
|
292
300
|
|
|
293
|
-
### Logistics & Inventory (
|
|
301
|
+
### Logistics & Inventory (17 functions)
|
|
294
302
|
|
|
295
303
|
```typescript
|
|
296
|
-
import { cbm, eoq, safetyStock, kanban } from 'formulab/logistics';
|
|
304
|
+
import { cbm, eoq, safetyStock, kanban, inventoryTurnover, abcAnalysis } from 'formulab/logistics';
|
|
297
305
|
```
|
|
298
306
|
|
|
299
307
|
| Function | Description |
|
|
300
308
|
|----------|-------------|
|
|
309
|
+
| `abcAnalysis()` | ABC inventory classification by annual value |
|
|
301
310
|
| `cbm()` | Cubic meter calculation |
|
|
302
311
|
| `containerFit()` | Container capacity estimation |
|
|
303
312
|
| `dimWeight()` | Dimensional weight |
|
|
304
313
|
| `eoq()` | Economic Order Quantity |
|
|
305
314
|
| `fillRate()` | Fill rate calculation |
|
|
306
315
|
| `freightClass()` | NMFC freight class |
|
|
316
|
+
| `inventoryTurnover()` | Inventory turnover ratio & days of supply |
|
|
307
317
|
| `kanban()` | Kanban quantity |
|
|
318
|
+
| `loadCapacity()` | Forklift load capacity derating |
|
|
308
319
|
| `pallet3d()` | 3D pallet loading heuristic (BLF + FFD) |
|
|
309
320
|
| `palletStack()` | Pallet stacking calculation |
|
|
310
321
|
| `pickTime()` | Picking time estimation |
|
|
@@ -313,42 +324,57 @@ import { cbm, eoq, safetyStock, kanban } from 'formulab/logistics';
|
|
|
313
324
|
| `shipping()` | Shipping cost estimation |
|
|
314
325
|
| `tsp()` | TSP heuristic (NN + 2-Opt; exact for n ≤ 10) |
|
|
315
326
|
|
|
316
|
-
### Energy & Utilities (
|
|
327
|
+
### Energy & Utilities (15 functions)
|
|
317
328
|
|
|
318
329
|
```typescript
|
|
319
|
-
import { powerCost, motorEfficiency, carbonFootprint, solarOutput } from 'formulab/energy';
|
|
330
|
+
import { powerCost, motorEfficiency, carbonFootprint, solarOutput, boilerEfficiency, heatPump, cusum } from 'formulab/energy';
|
|
320
331
|
```
|
|
321
332
|
|
|
322
333
|
| Function | Description |
|
|
323
334
|
|----------|-------------|
|
|
324
|
-
| `
|
|
335
|
+
| `boilerEfficiency()` | Boiler thermal efficiency (direct method) |
|
|
325
336
|
| `carbonFootprint()` | Scope 2 emissions |
|
|
326
337
|
| `compressedAirCost()` | Compressed air cost |
|
|
338
|
+
| `cusum()` | CUSUM energy anomaly detection |
|
|
339
|
+
| `degreeDay()` | Heating/Cooling degree days (HDD/CDD) |
|
|
340
|
+
| `heatPump()` | Heat pump COP & Carnot efficiency |
|
|
341
|
+
| `insulationRoi()` | Insulation ROI & payback |
|
|
342
|
+
| `ledRoi()` | LED lighting retrofit ROI |
|
|
327
343
|
| `motorEfficiency()` | Motor upgrade ROI |
|
|
328
344
|
| `pfCorrection()` | Power factor correction |
|
|
329
345
|
| `powerCost()` | Electricity cost with demand |
|
|
346
|
+
| `solarOutput()` | Solar panel output estimation (PVWatts-based) |
|
|
347
|
+
| `transformerLoss()` | Transformer loss & efficiency |
|
|
330
348
|
| `vfdSavings()` | VFD energy savings |
|
|
349
|
+
| `windOutput()` | Wind turbine output with Rayleigh CF |
|
|
331
350
|
|
|
332
|
-
### Safety & Ergonomics (
|
|
351
|
+
### Safety & Ergonomics (14 functions)
|
|
333
352
|
|
|
334
353
|
```typescript
|
|
335
|
-
import { nioshLifting, noiseExposure, wbgtCalculate, ventilationRate } from 'formulab/safety';
|
|
354
|
+
import { nioshLifting, noiseExposure, wbgtCalculate, ventilationRate, thermalComfort, arcFlash, lel } from 'formulab/safety';
|
|
336
355
|
```
|
|
337
356
|
|
|
338
357
|
| Function | Description |
|
|
339
358
|
|----------|-------------|
|
|
340
|
-
| `
|
|
359
|
+
| `arcFlash()` | Arc flash incident energy & PPE (IEEE 1584) |
|
|
360
|
+
| `confinedSpace()` | Confined space atmospheric assessment (OSHA) |
|
|
361
|
+
| `ergonomicRisk()` | REBA ergonomic risk scoring |
|
|
341
362
|
| `fallClearance()` | Fall protection clearance |
|
|
363
|
+
| `havsCalculate()` | Hand-arm vibration exposure |
|
|
364
|
+
| `illuminance()` | Workplace illuminance (Lumen Method) |
|
|
365
|
+
| `ladderAngle()` | Ladder safety angle (OSHA 4:1) |
|
|
366
|
+
| `lel()` | Mixed gas LEL (Le Chatelier's rule) |
|
|
342
367
|
| `nioshLifting()` | NIOSH lifting equation |
|
|
343
368
|
| `noiseExposure()` | TWA/Dose calculation |
|
|
344
|
-
| `wbgtCalculate()` | WBGT heat stress index |
|
|
345
|
-
| `havsCalculate()` | Hand-arm vibration exposure |
|
|
346
369
|
| `respiratorCalculate()` | Respirator MUC calculation |
|
|
370
|
+
| `thermalComfort()` | PMV/PPD thermal comfort (ISO 7730) |
|
|
371
|
+
| `ventilationRate()` | Required ventilation ACH/CFM (ASHRAE/OSHA) |
|
|
372
|
+
| `wbgtCalculate()` | WBGT heat stress index |
|
|
347
373
|
|
|
348
|
-
### Food & HACCP (
|
|
374
|
+
### Food & HACCP (6 functions)
|
|
349
375
|
|
|
350
376
|
```typescript
|
|
351
|
-
import { calorie, nutrition, haccp } from 'formulab/food';
|
|
377
|
+
import { calorie, nutrition, haccp, waterActivity, stabilityStudy } from 'formulab/food';
|
|
352
378
|
```
|
|
353
379
|
|
|
354
380
|
| Function | Description |
|
|
@@ -357,18 +383,34 @@ import { calorie, nutrition, haccp } from 'formulab/food';
|
|
|
357
383
|
| `expiry()` | Expiry date calculation |
|
|
358
384
|
| `nutrition()` | Nutrition facts calculation |
|
|
359
385
|
| `haccp()` | HACCP checklist generation |
|
|
386
|
+
| `waterActivity()` | Water activity microbial risk (HACCP) |
|
|
387
|
+
| `stabilityStudy()` | Accelerated stability (Arrhenius, ICH Q1A) |
|
|
360
388
|
|
|
361
|
-
### Utility (
|
|
389
|
+
### Utility (16 functions)
|
|
362
390
|
|
|
363
391
|
```typescript
|
|
364
|
-
import { solveAssignment, calculateUnit } from 'formulab/utility';
|
|
392
|
+
import { solveAssignment, calculateUnit, statistics, regression, npv } from 'formulab/utility';
|
|
365
393
|
```
|
|
366
394
|
|
|
367
395
|
| Function | Description |
|
|
368
396
|
|----------|-------------|
|
|
369
397
|
| `solveAssignment()` | Hungarian algorithm optimization |
|
|
370
|
-
| `calculateUnit()` | Unit conversion |
|
|
398
|
+
| `calculateUnit()` | Unit conversion (7 categories) |
|
|
371
399
|
| `getUnitCategories()` | Get unit categories |
|
|
400
|
+
| `statistics()` | Descriptive statistics (mean, median, stdDev, etc.) |
|
|
401
|
+
| `percentile()` | Percentile/quantile calculation |
|
|
402
|
+
| `correlation()` | Pearson correlation coefficient |
|
|
403
|
+
| `regression()` | Simple linear regression |
|
|
404
|
+
| `movingAverage()` | SMA/EMA/WMA moving average |
|
|
405
|
+
| `linearInterpolation()` | 1D linear interpolation |
|
|
406
|
+
| `bilinearInterpolation()` | 2D bilinear interpolation |
|
|
407
|
+
| `roi()` | Return on Investment |
|
|
408
|
+
| `npv()` | Net Present Value |
|
|
409
|
+
| `depreciation()` | Asset depreciation (SL/DDB/SYD) |
|
|
410
|
+
| `lcc()` | Life Cycle Cost analysis |
|
|
411
|
+
| `normalize()` | Data normalization (min-max/z-score) |
|
|
412
|
+
| `histogram()` | Frequency distribution histogram |
|
|
413
|
+
| `weightedScore()` | Weighted scoring model |
|
|
372
414
|
|
|
373
415
|
### Battery (10 functions)
|
|
374
416
|
|
|
@@ -499,6 +541,54 @@ console.log(result);
|
|
|
499
541
|
// }
|
|
500
542
|
```
|
|
501
543
|
|
|
544
|
+
## Type Guards for Discriminated Unions
|
|
545
|
+
|
|
546
|
+
formulab provides runtime type guard functions for all [discriminated union](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions) input types. These enable type-safe integration when working with dynamic data (e.g., form inputs, API responses):
|
|
547
|
+
|
|
548
|
+
```typescript
|
|
549
|
+
import { isCRateInput, cRate } from 'formulab/battery';
|
|
550
|
+
|
|
551
|
+
// Form data from user input (Record<string, unknown>)
|
|
552
|
+
const formData: unknown = { mode: 'currentToRate', capacityAh: 100, currentA: 50 };
|
|
553
|
+
|
|
554
|
+
if (isCRateInput(formData)) {
|
|
555
|
+
const result = cRate(formData); // Type-safe, no 'as any' needed
|
|
556
|
+
}
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
### Available Type Guards
|
|
560
|
+
|
|
561
|
+
| Guard | Domain | Discriminant | Variants |
|
|
562
|
+
|-------|--------|-------------|----------|
|
|
563
|
+
| `isCRateInput()` | battery | `mode` | currentToRate, rateToCurrent |
|
|
564
|
+
| `isDilutionInput()` | chemical | `solveFor` | c1, v1, c2, v2 |
|
|
565
|
+
| `isReactorInput()` | chemical | `shape` | cylindrical, spherical |
|
|
566
|
+
| `isHeatTransferInput()` | chemical | `mode` | conduction, convection, radiation |
|
|
567
|
+
| `isMomentOfInertiaInput()` | construction | `shape` | rectangle, circle, hollowRectangle, hollowCircle, iBeam, tSection, cChannel |
|
|
568
|
+
| `isOhmsLawInput()` | electronics | `solveFor` | voltage, current, resistance, power |
|
|
569
|
+
| `isMetalWeightInput()` | metal | `shape` | plate, round, pipe, angle |
|
|
570
|
+
| `isBoltInput()` | metal | `mode` | torqueToPreload, preloadToTorque |
|
|
571
|
+
|
|
572
|
+
## Error Handling
|
|
573
|
+
|
|
574
|
+
See [ERRORS.md](./ERRORS.md) for the complete error behavior specification. Key points:
|
|
575
|
+
|
|
576
|
+
- **All validation failures** throw `RangeError` with descriptive messages
|
|
577
|
+
- **No silent NaN/Infinity** — every function guarantees finite outputs for valid inputs
|
|
578
|
+
- Every `@throws` condition is documented in each function's JSDoc
|
|
579
|
+
|
|
580
|
+
```typescript
|
|
581
|
+
import { metalWeight } from 'formulab/metal';
|
|
582
|
+
|
|
583
|
+
try {
|
|
584
|
+
const result = metalWeight({ shape: 'plate', materialName: 'steel', length: 0, width: 100, thickness: 10 });
|
|
585
|
+
} catch (e) {
|
|
586
|
+
if (e instanceof RangeError) {
|
|
587
|
+
console.log(e.message); // "length must be positive"
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
```
|
|
591
|
+
|
|
502
592
|
## Tree Shaking
|
|
503
593
|
|
|
504
594
|
Import only what you need to minimize bundle size:
|
|
@@ -9,6 +9,10 @@ import type { BrakingDistanceInput, BrakingDistanceResult } from './types.js';
|
|
|
9
9
|
*
|
|
10
10
|
* Reference: AASHTO "A Policy on Geometric Design of Highways and Streets"
|
|
11
11
|
*
|
|
12
|
+
* @throws {RangeError} Speed must be positive
|
|
13
|
+
* @throws {RangeError} Friction coefficient must be positive
|
|
14
|
+
* @throws {RangeError} Reaction time must be non-negative
|
|
15
|
+
* @throws {RangeError} Effective friction (friction + grade) must be positive — vehicle cannot stop on this grade
|
|
12
16
|
* @param input - speed, friction, reaction time, grade
|
|
13
17
|
* @returns stopping distance components
|
|
14
18
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brakingDistance.d.ts","sourceRoot":"","sources":["../../src/automotive/brakingDistance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE9E
|
|
1
|
+
{"version":3,"file":"brakingDistance.d.ts","sourceRoot":"","sources":["../../src/automotive/brakingDistance.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAE9E;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,oBAAoB,GAAG,qBAAqB,CAqClF"}
|
|
@@ -9,17 +9,21 @@ import { roundTo } from '../utils.js';
|
|
|
9
9
|
*
|
|
10
10
|
* Reference: AASHTO "A Policy on Geometric Design of Highways and Streets"
|
|
11
11
|
*
|
|
12
|
+
* @throws {RangeError} Speed must be positive
|
|
13
|
+
* @throws {RangeError} Friction coefficient must be positive
|
|
14
|
+
* @throws {RangeError} Reaction time must be non-negative
|
|
15
|
+
* @throws {RangeError} Effective friction (friction + grade) must be positive — vehicle cannot stop on this grade
|
|
12
16
|
* @param input - speed, friction, reaction time, grade
|
|
13
17
|
* @returns stopping distance components
|
|
14
18
|
*/
|
|
15
19
|
export function brakingDistance(input) {
|
|
16
20
|
const { speed, friction, reactionTime, grade } = input;
|
|
17
21
|
if (speed <= 0)
|
|
18
|
-
throw new
|
|
22
|
+
throw new RangeError('Speed must be positive');
|
|
19
23
|
if (friction <= 0)
|
|
20
|
-
throw new
|
|
24
|
+
throw new RangeError('Friction coefficient must be positive');
|
|
21
25
|
if (reactionTime < 0)
|
|
22
|
-
throw new
|
|
26
|
+
throw new RangeError('Reaction time must be non-negative');
|
|
23
27
|
const g = 9.81; // m/s²
|
|
24
28
|
const speedMps = speed / 3.6; // km/h → m/s
|
|
25
29
|
const gradeDecimal = grade / 100; // % → decimal
|
|
@@ -29,7 +33,7 @@ export function brakingDistance(input) {
|
|
|
29
33
|
// Uphill (positive grade) helps braking, downhill (negative) hinders
|
|
30
34
|
const effectiveFriction = friction + gradeDecimal;
|
|
31
35
|
if (effectiveFriction <= 0) {
|
|
32
|
-
throw new
|
|
36
|
+
throw new RangeError('Effective friction (friction + grade) must be positive — vehicle cannot stop on this grade');
|
|
33
37
|
}
|
|
34
38
|
// Deceleration: a = g × (f ± G)
|
|
35
39
|
const deceleration = g * effectiveFriction;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"brakingDistance.js","sourceRoot":"","sources":["../../src/automotive/brakingDistance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC
|
|
1
|
+
{"version":3,"file":"brakingDistance.js","sourceRoot":"","sources":["../../src/automotive/brakingDistance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,eAAe,CAAC,KAA2B;IACzD,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,GAAG,KAAK,CAAC;IAEvD,IAAI,KAAK,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,wBAAwB,CAAC,CAAC;IAC/D,IAAI,QAAQ,IAAI,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,uCAAuC,CAAC,CAAC;IACjF,IAAI,YAAY,GAAG,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,oCAAoC,CAAC,CAAC;IAEjF,MAAM,CAAC,GAAG,IAAI,CAAC,CAAC,OAAO;IACvB,MAAM,QAAQ,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC,aAAa;IAC3C,MAAM,YAAY,GAAG,KAAK,GAAG,GAAG,CAAC,CAAC,cAAc;IAEhD,+BAA+B;IAC/B,MAAM,YAAY,GAAG,QAAQ,GAAG,YAAY,CAAC;IAE7C,uCAAuC;IACvC,qEAAqE;IACrE,MAAM,iBAAiB,GAAG,QAAQ,GAAG,YAAY,CAAC;IAElD,IAAI,iBAAiB,IAAI,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,UAAU,CAAC,4FAA4F,CAAC,CAAC;IACrH,CAAC;IAED,gCAAgC;IAChC,MAAM,YAAY,GAAG,CAAC,GAAG,iBAAiB,CAAC;IAE3C,qCAAqC;IACrC,MAAM,WAAW,GAAG,CAAC,QAAQ,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,YAAY,CAAC,CAAC;IAE/D,MAAM,qBAAqB,GAAG,YAAY,GAAG,WAAW,CAAC;IAEzD,OAAO;QACL,gBAAgB,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;QAC1C,eAAe,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QACxC,qBAAqB,EAAE,OAAO,CAAC,qBAAqB,EAAE,CAAC,CAAC;QACxD,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC9B,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;KACvC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ChargingLossInput, ChargingLossResult } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* EV Charging Loss Calculator
|
|
4
|
+
*
|
|
5
|
+
* @formula
|
|
6
|
+
* - energyDelivered = batteryCapacity × (targetSoc − soc) / 100
|
|
7
|
+
* - energyConsumed = energyDelivered / (chargerEff × batteryEff)
|
|
8
|
+
* - totalLoss = energyConsumed − energyDelivered
|
|
9
|
+
* - chargingTime = energyConsumed / effectivePower
|
|
10
|
+
*
|
|
11
|
+
* @reference SAE J1772 — Electric Vehicle Charging
|
|
12
|
+
* @reference IEC 61851 — Electric vehicle conductive charging system
|
|
13
|
+
*/
|
|
14
|
+
export declare function chargingLoss(input: ChargingLossInput): ChargingLossResult;
|
|
15
|
+
//# sourceMappingURL=chargingLoss.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chargingLoss.d.ts","sourceRoot":"","sources":["../../src/automotive/chargingLoss.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AASxE;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,kBAAkB,CAiDzE"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { roundTo } from '../utils.js';
|
|
2
|
+
// Default charger efficiencies by type
|
|
3
|
+
const DEFAULT_CHARGER_EFFICIENCY = {
|
|
4
|
+
ac_l1: 0.85,
|
|
5
|
+
ac_l2: 0.90,
|
|
6
|
+
dc_fast: 0.93,
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* EV Charging Loss Calculator
|
|
10
|
+
*
|
|
11
|
+
* @formula
|
|
12
|
+
* - energyDelivered = batteryCapacity × (targetSoc − soc) / 100
|
|
13
|
+
* - energyConsumed = energyDelivered / (chargerEff × batteryEff)
|
|
14
|
+
* - totalLoss = energyConsumed − energyDelivered
|
|
15
|
+
* - chargingTime = energyConsumed / effectivePower
|
|
16
|
+
*
|
|
17
|
+
* @reference SAE J1772 — Electric Vehicle Charging
|
|
18
|
+
* @reference IEC 61851 — Electric vehicle conductive charging system
|
|
19
|
+
*/
|
|
20
|
+
export function chargingLoss(input) {
|
|
21
|
+
const { batteryCapacity, chargerPower, chargerType, batteryEfficiency = 0.95, soc, ambientTemp, } = input;
|
|
22
|
+
const chargerEfficiency = input.chargerEfficiency ?? DEFAULT_CHARGER_EFFICIENCY[chargerType] ?? 0.90;
|
|
23
|
+
const targetSoc = input.targetSoc ?? (chargerType === 'dc_fast' ? 80 : 100);
|
|
24
|
+
// Temperature derating
|
|
25
|
+
let derating = 1.0;
|
|
26
|
+
if (ambientTemp != null) {
|
|
27
|
+
if (ambientTemp < 0) {
|
|
28
|
+
derating = 0.70; // Cold weather significant derating
|
|
29
|
+
}
|
|
30
|
+
else if (ambientTemp < 10) {
|
|
31
|
+
derating = 0.85;
|
|
32
|
+
}
|
|
33
|
+
else if (ambientTemp > 40) {
|
|
34
|
+
derating = 0.90;
|
|
35
|
+
}
|
|
36
|
+
else if (ambientTemp > 35) {
|
|
37
|
+
derating = 0.95;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
const effectivePower = chargerPower * derating;
|
|
41
|
+
// Energy calculations
|
|
42
|
+
const energyDelivered = batteryCapacity * (targetSoc - soc) / 100;
|
|
43
|
+
const overallEff = chargerEfficiency * batteryEfficiency;
|
|
44
|
+
const energyConsumed = overallEff > 0 ? energyDelivered / overallEff : 0;
|
|
45
|
+
const totalLoss = energyConsumed - energyDelivered;
|
|
46
|
+
// Loss breakdown
|
|
47
|
+
const chargerLoss = energyConsumed * (1 - chargerEfficiency);
|
|
48
|
+
const batteryLoss = (energyConsumed - chargerLoss) * (1 - batteryEfficiency);
|
|
49
|
+
// Charging time
|
|
50
|
+
const chargingTime = effectivePower > 0 ? energyConsumed / effectivePower : 0;
|
|
51
|
+
return {
|
|
52
|
+
energyDelivered: roundTo(energyDelivered, 2),
|
|
53
|
+
energyConsumed: roundTo(energyConsumed, 2),
|
|
54
|
+
totalLoss: roundTo(totalLoss, 2),
|
|
55
|
+
overallEfficiency: roundTo(overallEff * 100, 2),
|
|
56
|
+
chargerLoss: roundTo(chargerLoss, 2),
|
|
57
|
+
batteryLoss: roundTo(batteryLoss, 2),
|
|
58
|
+
chargingTime: roundTo(chargingTime, 2),
|
|
59
|
+
effectivePower: roundTo(effectivePower, 2),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=chargingLoss.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chargingLoss.js","sourceRoot":"","sources":["../../src/automotive/chargingLoss.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGtC,uCAAuC;AACvC,MAAM,0BAA0B,GAA2B;IACzD,KAAK,EAAE,IAAI;IACX,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,IAAI;CACd,CAAC;AAEF;;;;;;;;;;;GA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IACjB,MAAM,WAAW,GAAG,cAAc,GAAG,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC;IAC7D,MAAM,WAAW,GAAG,CAAC,cAAc,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC;IAE7E,gBAAgB;IAChB,MAAM,YAAY,GAAG,cAAc,GAAG,CAAC,CAAC,CAAC,CAAC,cAAc,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAE9E,OAAO;QACL,eAAe,EAAE,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;QAC5C,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;QAC1C,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC,CAAC;QAChC,iBAAiB,EAAE,OAAO,CAAC,UAAU,GAAG,GAAG,EAAE,CAAC,CAAC;QAC/C,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QACpC,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC;QACpC,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC,CAAC;QACtC,cAAc,EAAE,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -6,5 +6,6 @@ export { gearRatio } from './gearRatio.js';
|
|
|
6
6
|
export { tireCompare } from './tireCompare.js';
|
|
7
7
|
export { torque } from './torque.js';
|
|
8
8
|
export { power } from './power.js';
|
|
9
|
-
export
|
|
9
|
+
export { chargingLoss } from './chargingLoss.js';
|
|
10
|
+
export type { BrakingDistanceInput, BrakingDistanceResult, BatteryInput, BatteryResult, ChargingInput, ChargingResult, FuelUnit, FuelInput, FuelResult, GearRatioInput, GearRatioResult, TireSpec, TireInput, TireData, TireResult, TorqueUnit, TorqueInput, TorqueResult, PowerUnit, PowerInput, PowerResult, ChargingLossInput, ChargingLossResult, } from './types.js';
|
|
10
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/automotive/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/automotive/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAGjD,YAAY,EAEV,oBAAoB,EACpB,qBAAqB,EAErB,YAAY,EACZ,aAAa,EAEb,aAAa,EACb,cAAc,EAEd,QAAQ,EACR,SAAS,EACT,UAAU,EAEV,cAAc,EACd,eAAe,EAEf,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,UAAU,EAEV,UAAU,EACV,WAAW,EACX,YAAY,EAEZ,SAAS,EACT,UAAU,EACV,WAAW,EAEX,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,YAAY,CAAC"}
|
package/dist/automotive/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/automotive/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/automotive/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -127,4 +127,27 @@ export interface PowerResult {
|
|
|
127
127
|
HP: number;
|
|
128
128
|
PS: number;
|
|
129
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* EV Charging Loss Calculator Types
|
|
132
|
+
*/
|
|
133
|
+
export interface ChargingLossInput {
|
|
134
|
+
batteryCapacity: number;
|
|
135
|
+
chargerPower: number;
|
|
136
|
+
chargerType: 'ac_l1' | 'ac_l2' | 'dc_fast';
|
|
137
|
+
chargerEfficiency?: number;
|
|
138
|
+
batteryEfficiency?: number;
|
|
139
|
+
soc: number;
|
|
140
|
+
targetSoc?: number;
|
|
141
|
+
ambientTemp?: number;
|
|
142
|
+
}
|
|
143
|
+
export interface ChargingLossResult {
|
|
144
|
+
energyDelivered: number;
|
|
145
|
+
energyConsumed: number;
|
|
146
|
+
totalLoss: number;
|
|
147
|
+
overallEfficiency: number;
|
|
148
|
+
chargerLoss: number;
|
|
149
|
+
batteryLoss: number;
|
|
150
|
+
chargingTime: number;
|
|
151
|
+
effectivePower: number;
|
|
152
|
+
}
|
|
130
153
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/automotive/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE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