@spaceteams/weft-layer-dimensional 0.5.1 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +10 -12
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LayerEvaluator } from "@spaceteams/weft";
|
|
2
|
-
|
|
3
2
|
//#region src/unit.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* A rational unit representation using sorted base-unit arrays.
|
|
@@ -12,22 +11,22 @@ import { LayerEvaluator } from "@spaceteams/weft";
|
|
|
12
11
|
* - metres per second: `{ num: ["m"], denom: ["s"] }`
|
|
13
12
|
* - dimensionless: `{ num: [], denom: [] }`
|
|
14
13
|
*/
|
|
15
|
-
type Unit = {
|
|
14
|
+
export type Unit = {
|
|
16
15
|
readonly num: readonly string[];
|
|
17
16
|
readonly denom: readonly string[];
|
|
18
17
|
};
|
|
19
18
|
/** Create a base unit, e.g. `unit("m")` → `{ num: ["m"], denom: [] }`. */
|
|
20
|
-
declare function unit(name: string): Unit;
|
|
19
|
+
export declare function unit(name: string): Unit;
|
|
21
20
|
/** The dimensionless unit (scalar). */
|
|
22
|
-
declare function dimensionless(): Unit;
|
|
21
|
+
export declare function dimensionless(): Unit;
|
|
23
22
|
/** Create an arbitrary compound unit from numerator and denominator base units. */
|
|
24
|
-
declare function compoundUnit(num: readonly string[], denom: readonly string[]): Unit;
|
|
23
|
+
export declare function compoundUnit(num: readonly string[], denom: readonly string[]): Unit;
|
|
25
24
|
/** Multiply two units: `(a·b)`. Combines numerators and denominators, cancelling common factors. */
|
|
26
|
-
declare function multiplyUnits(a: Unit, b: Unit): Unit;
|
|
25
|
+
export declare function multiplyUnits(a: Unit, b: Unit): Unit;
|
|
27
26
|
/** Divide two units: `a / b`. */
|
|
28
|
-
declare function divideUnits(a: Unit, b: Unit): Unit;
|
|
27
|
+
export declare function divideUnits(a: Unit, b: Unit): Unit;
|
|
29
28
|
/** Structural equality of two units. */
|
|
30
|
-
declare function unitsEqual(a: Unit, b: Unit): boolean;
|
|
29
|
+
export declare function unitsEqual(a: Unit, b: Unit): boolean;
|
|
31
30
|
/**
|
|
32
31
|
* Format a unit as a human-readable string.
|
|
33
32
|
*
|
|
@@ -38,7 +37,7 @@ declare function unitsEqual(a: Unit, b: Unit): boolean;
|
|
|
38
37
|
* - `"1"` — dimensionless
|
|
39
38
|
* - `"1/s"` — pure denominator
|
|
40
39
|
*/
|
|
41
|
-
declare function formatUnit(u: Unit): string;
|
|
40
|
+
export declare function formatUnit(u: Unit): string;
|
|
42
41
|
//#endregion
|
|
43
42
|
//#region src/dimensional-layer.d.ts
|
|
44
43
|
/**
|
|
@@ -48,6 +47,5 @@ declare function formatUnit(u: Unit): string;
|
|
|
48
47
|
* rule's `op`. When units are incompatible (e.g. adding metres to seconds),
|
|
49
48
|
* the layer returns `undefined` — it never throws.
|
|
50
49
|
*/
|
|
51
|
-
declare const dimensionalLayer: LayerEvaluator<Unit>;
|
|
52
|
-
//#endregion
|
|
53
|
-
export { Unit, compoundUnit, dimensionalLayer, dimensionless, divideUnits, formatUnit, multiplyUnits, unit, unitsEqual };
|
|
50
|
+
export declare const dimensionalLayer: LayerEvaluator<Unit>;
|
|
51
|
+
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -99,7 +99,7 @@ function arraysEqual(a, b) {
|
|
|
99
99
|
*/
|
|
100
100
|
const dimensionalLayer = {
|
|
101
101
|
name: "units",
|
|
102
|
-
version: "
|
|
102
|
+
version: "2",
|
|
103
103
|
eval(op, deps, spec) {
|
|
104
104
|
switch (op) {
|
|
105
105
|
case "sum":
|
|
@@ -130,7 +130,7 @@ const dimensionalLayer = {
|
|
|
130
130
|
case "future-value":
|
|
131
131
|
case "annuity-payment":
|
|
132
132
|
case "present-value": return financialUnit(deps, spec);
|
|
133
|
-
case "match": return
|
|
133
|
+
case "match": return;
|
|
134
134
|
case "compare":
|
|
135
135
|
case "and":
|
|
136
136
|
case "or":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spaceteams/weft-layer-dimensional",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "SI unit propagation and dimensional analysis layer for @spaceteams/weft",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
],
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@spaceteams/weft": "0.
|
|
30
|
+
"@spaceteams/weft": "0.7.0"
|
|
31
31
|
},
|
|
32
32
|
"scripts": {
|
|
33
33
|
"build": "tsdown",
|