formulab 0.13.3 → 0.13.4

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 CHANGED
@@ -5,6 +5,16 @@ 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.13.4] - 2026-06-18
9
+
10
+ ### Changed (breaking within 0.x)
11
+
12
+ - **`earthwork()` / `formwork()` (construction): zero-filled result on invalid input migrated to the standard error policy** — both functions previously returned an all-zero result for non-positive dimensions instead of throwing, and their existing tests encoded that as an "edge case". They now **throw `RangeError`** with a per-constraint message, matching `ERRORS.md` (which already documented them as `throw`) and the beamLoad/compressedAirCost migrations:
13
+ - `earthwork()`: non-positive `length`/`width`/`depth`, or non-positive `swellFactor`/`shrinkFactor` (a zero factor silently produced a zero loose/compacted volume).
14
+ - `formwork()`: non-positive dimension **consumed by the element type's area formula** (column/beam/footing → length, width, height; slab → length, width; wall → length, height) or non-positive `quantity`. Dimensions a given element type ignores (slab height, wall width) are left unvalidated, so a formula-irrelevant zero is still accepted. `reuses ≤ 0 → 1` remains intentional lenient behavior.
15
+
16
+ Reported by online-tools: ISSUE-20260618-formulab-earthwork-formwork-zerofill (NT-9). `ERRORS.md` condition text updated from "Negative dimensions" to the precise non-positive constraints.
17
+
8
18
  ## [0.13.3] - 2026-06-12
9
19
 
10
20
  ### Changed (breaking within 0.x)
@@ -8,6 +8,8 @@ import type { EarthworkInput, EarthworkResult } from './types.js';
8
8
  *
9
9
  * @param input - Earthwork dimensions and factors
10
10
  * @returns Volume calculations in m³
11
+ * @throws RangeError if any dimension (length, width, depth) is not positive,
12
+ * or if swellFactor/shrinkFactor is not positive
11
13
  */
12
14
  export declare function earthwork(input: EarthworkInput): EarthworkResult;
13
15
  //# sourceMappingURL=earthwork.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"earthwork.d.ts","sourceRoot":"","sources":["../../src/construction/earthwork.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElE;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CAiBhE"}
1
+ {"version":3,"file":"earthwork.d.ts","sourceRoot":"","sources":["../../src/construction/earthwork.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElE;;;;;;;;;;;GAWG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,eAAe,CAiChE"}
@@ -7,9 +7,26 @@
7
7
  *
8
8
  * @param input - Earthwork dimensions and factors
9
9
  * @returns Volume calculations in m³
10
+ * @throws RangeError if any dimension (length, width, depth) is not positive,
11
+ * or if swellFactor/shrinkFactor is not positive
10
12
  */
11
13
  export function earthwork(input) {
12
14
  const { length, width, depth, swellFactor, shrinkFactor } = input;
15
+ if (length <= 0) {
16
+ throw new RangeError('length must be greater than 0');
17
+ }
18
+ if (width <= 0) {
19
+ throw new RangeError('width must be greater than 0');
20
+ }
21
+ if (depth <= 0) {
22
+ throw new RangeError('depth must be greater than 0');
23
+ }
24
+ if (swellFactor <= 0) {
25
+ throw new RangeError('swellFactor must be greater than 0');
26
+ }
27
+ if (shrinkFactor <= 0) {
28
+ throw new RangeError('shrinkFactor must be greater than 0');
29
+ }
13
30
  // Bank volume = undisturbed volume
14
31
  const bankVolume = length * width * depth;
15
32
  // Loose volume = bank volume × swell factor
@@ -1 +1 @@
1
- {"version":3,"file":"earthwork.js","sourceRoot":"","sources":["../../src/construction/earthwork.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CAAC,KAAqB;IAC7C,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,WAAW,EA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AG,UAAU,GAAG,YAAY,CAAC;IAElD,OAAO;QACL,UAAU;QACV,WAAW;QACX,eAAe;KAChB,CAAC;AACJ,CAAC"}
@@ -4,6 +4,9 @@ import type { FormworkInput, FormworkResult } from './types.js';
4
4
  *
5
5
  * @param input - Formwork calculation parameters
6
6
  * @returns Formwork area results
7
+ * @throws RangeError if a dimension consumed by the element type's area formula
8
+ * is not positive (column/beam/footing: length, width, height; slab: length,
9
+ * width; wall: length, height), or if quantity is not positive
7
10
  */
8
11
  export declare function formwork(input: FormworkInput): FormworkResult;
9
12
  //# sourceMappingURL=formwork.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"formwork.d.ts","sourceRoot":"","sources":["../../src/construction/formwork.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAgD7E;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,cAAc,CAwB7D"}
1
+ {"version":3,"file":"formwork.d.ts","sourceRoot":"","sources":["../../src/construction/formwork.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,aAAa,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA8E7E;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,aAAa,GAAG,cAAc,CA8B7D"}
@@ -32,14 +32,49 @@ function calculateSingleArea(elementType, length, width, height) {
32
32
  return 0;
33
33
  }
34
34
  }
35
+ /**
36
+ * Validate that the dimensions actually consumed by an element type's area
37
+ * formula are positive. Dimensions not used by a given element type are left
38
+ * unvalidated (e.g. a slab ignores height, a wall ignores width).
39
+ */
40
+ function validateDimensions(elementType, length, width, height) {
41
+ if (length <= 0) {
42
+ throw new RangeError('length must be greater than 0');
43
+ }
44
+ switch (elementType) {
45
+ case 'column':
46
+ case 'beam':
47
+ case 'footing':
48
+ if (width <= 0)
49
+ throw new RangeError('width must be greater than 0');
50
+ if (height <= 0)
51
+ throw new RangeError('height must be greater than 0');
52
+ break;
53
+ case 'slab':
54
+ if (width <= 0)
55
+ throw new RangeError('width must be greater than 0');
56
+ break;
57
+ case 'wall':
58
+ if (height <= 0)
59
+ throw new RangeError('height must be greater than 0');
60
+ break;
61
+ }
62
+ }
35
63
  /**
36
64
  * Calculate formwork area requirements
37
65
  *
38
66
  * @param input - Formwork calculation parameters
39
67
  * @returns Formwork area results
68
+ * @throws RangeError if a dimension consumed by the element type's area formula
69
+ * is not positive (column/beam/footing: length, width, height; slab: length,
70
+ * width; wall: length, height), or if quantity is not positive
40
71
  */
41
72
  export function formwork(input) {
42
73
  const { elementType, length, width, height, quantity, reuses } = input;
74
+ validateDimensions(elementType, length, width, height);
75
+ if (quantity <= 0) {
76
+ throw new RangeError('quantity must be greater than 0');
77
+ }
43
78
  // Calculate area for single element
44
79
  const singleAreaSqm = calculateSingleArea(elementType, length, width, height);
45
80
  // Total area = single area × quantity
@@ -1 +1 @@
1
- {"version":3,"file":"formwork.js","sourceRoot":"","sources":["../../src/construction/formwork.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEtC;;GAEG;AACH,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAElC;;;;;;;GAOG;AACH,SAAS,mBAAmB,CAC1B,WAAwB,EACxB,MAAc,EACd,KAAa,EACb,MAAc;IAEd,QAAQ,WAAW,EAAE,CAAC;QACpB,KAAK,QAAQ;YACX,gCAAgC;YAChC,OAAO,OAAO,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,KAAK,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;QAEnD,KAAK,MAAM;YACT,uCAAuC;YACvC,OAAO,OAAO,CAAC,CAAC,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,MAAM,EAAE,CAAC,CAAC,CAAC;QAE1D,KAAK,MAAM;YACT,4BAA4B;YAC5B,OAAO,OAAO,CAAC,MAAM,GAAG,KAAK,EA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OAAO;QACL,aAAa;QACb,YAAY;QACZ,gBAAgB;QAChB,aAAa;KACd,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "formulab",
3
- "version": "0.13.3",
3
+ "version": "0.13.4",
4
4
  "description": "Manufacturing & Engineering calculation formulas library - 182 industrial calculations across 15 domains for OEE, Cpk, SPC, FMEA, Nelson Rules, metal weight, CNC machining, GD&T, battery, environmental, pipe flow, logistics, IE time study, and more",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",