@thi.ng/units 0.3.1 → 0.4.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-03-16T11:22:27Z
3
+ - **Last updated**: 2023-03-27T19:05:48Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,15 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [0.4.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/units@0.4.0) (2023-03-22)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add US paper sizes/presets ([bc78668](https://github.com/thi-ng/umbrella/commit/bc78668))
17
+ - rename file din-sizes.ts => paper-sizes.ts
18
+ - update pkg export maps
19
+ - add landscape presets (paper sizes) ([a96a714](https://github.com/thi-ng/umbrella/commit/a96a714))
20
+
12
21
  ## [0.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/units@0.3.0) (2023-03-16)
13
22
 
14
23
  #### 🚀 Features
package/README.md CHANGED
@@ -545,17 +545,24 @@ convert(mul(quantity(10, "mm"), quantity(2, "in")), "cm2")
545
545
 
546
546
  The following constants are provided (more to come):
547
547
 
548
- | Var name | Unit | Comment |
549
- |---------------------------|-------------------|------------------------|
550
- | `DIN_A0` ... `DIN_A8` | 2d vector of `mm` | Paper sizes |
551
- | `EARTH_GRAVITY` | `m/s` | |
552
- | `EARTH_CIRCUMFERENCE` | `m` | |
553
- | `EARTH_MASS` | `kg` | |
554
- | `EARTH_RADIUS` | `m` | |
555
- | `GRAVITATION` | `kg-1·m3·s-2` | Gravitational constant |
556
- | `SPEED_OF_LIGHT` | `m/s` | |
557
- | `SPEED_OF_SOUND_IN_AIR` | `m/s` | at 20 ℃ |
558
- | `SPEED_OF_SOUND_IN_WATER` | `m/s` | at 20 ℃ |
548
+ | Var name | Unit | Comment |
549
+ |--------------------------------|---------------------|---------------------------|
550
+ | `DIN_A0` ... `DIN_A8` | 2d vector of `mm` | Paper sizes<sup>(1)</sup> |
551
+ | `EARTH_GRAVITY` | `m/s` | |
552
+ | `EARTH_CIRCUMFERENCE` | `m` | |
553
+ | `EARTH_MASS` | `kg` | |
554
+ | `EARTH_RADIUS` | `m` | |
555
+ | `GRAVITATION` | `kg-1·m3·s-2` | Gravitational constant |
556
+ | `SPEED_OF_LIGHT` | `m/s` | |
557
+ | `SPEED_OF_SOUND_IN_AIR` | `m/s` | at 20 ℃ |
558
+ | `SPEED_OF_SOUND_IN_WATER` | `m/s` | at 20 ℃ |
559
+ | `US_ANSI_A` ... `US_ANSI_E` | 2d vector of `inch` | Paper sizes<sup>(1)</sup> |
560
+ | `US_ARCH_A` ... `US_ARCH_E` | 2d vector of `inch` | Paper sizes<sup>(1)</sup> |
561
+ | `US_LETTER` / `US_HALF_LETTER` | 2d vector of `inch` | Paper sizes<sup>(1)</sup> |
562
+ | `US_LEGAL` / `US_JUNIOR_LEGAL` | 2d vector of `inch` | Paper sizes<sup>(1)</sup> |
563
+
564
+ - <sup>(1)</sup> - all paper sizes are also available as landscape presets
565
+ (using `_LANDSCAPE` as suffix).
559
566
 
560
567
  Densities of selected materials:
561
568
 
@@ -608,7 +615,7 @@ For Node.js REPL:
608
615
  const units = await import("@thi.ng/units");
609
616
  ```
610
617
 
611
- Package sizes (brotli'd, pre-treeshake): ESM: 4.37 KB
618
+ Package sizes (brotli'd, pre-treeshake): ESM: 4.77 KB
612
619
 
613
620
  ## Dependencies
614
621
 
@@ -0,0 +1,54 @@
1
+ import { Quantity } from "../unit.js";
2
+ export declare const DIN_A0: Quantity<number[]>;
3
+ export declare const DIN_A1: Quantity<number[]>;
4
+ export declare const DIN_A2: Quantity<number[]>;
5
+ export declare const DIN_A3: Quantity<number[]>;
6
+ export declare const DIN_A4: Quantity<number[]>;
7
+ export declare const DIN_A5: Quantity<number[]>;
8
+ export declare const DIN_A6: Quantity<number[]>;
9
+ export declare const DIN_A7: Quantity<number[]>;
10
+ export declare const DIN_A8: Quantity<number[]>;
11
+ export declare const DIN_A0_LANDSCAPE: Quantity<number[]>;
12
+ export declare const DIN_A1_LANDSCAPE: Quantity<number[]>;
13
+ export declare const DIN_A2_LANDSCAPE: Quantity<number[]>;
14
+ export declare const DIN_A3_LANDSCAPE: Quantity<number[]>;
15
+ export declare const DIN_A4_LANDSCAPE: Quantity<number[]>;
16
+ export declare const DIN_A5_LANDSCAPE: Quantity<number[]>;
17
+ export declare const DIN_A6_LANDSCAPE: Quantity<number[]>;
18
+ export declare const DIN_A7_LANDSCAPE: Quantity<number[]>;
19
+ export declare const DIN_A8_LANDSCAPE: Quantity<number[]>;
20
+ export declare const US_LETTER: Quantity<number[]>;
21
+ export declare const US_HALF_LETTER: Quantity<number[]>;
22
+ export declare const US_LEGAL: Quantity<number[]>;
23
+ export declare const US_JUNIOR_LEGAL: Quantity<number[]>;
24
+ export declare const US_LETTER_LANDSCAPE: Quantity<number[]>;
25
+ export declare const US_HALF_LETTER_LANDSCAPE: Quantity<number[]>;
26
+ export declare const US_LEGAL_LANDSCAPE: Quantity<number[]>;
27
+ export declare const US_JUNIOR_LEGAL_LANDSCAPE: Quantity<number[]>;
28
+ export declare const ANSI_A: Quantity<number[]>;
29
+ export declare const ANSI_B: Quantity<number[]>;
30
+ export declare const ANSI_C: Quantity<number[]>;
31
+ export declare const ANSI_D: Quantity<number[]>;
32
+ export declare const ANSI_E: Quantity<number[]>;
33
+ export declare const ANSI_A_LANDSCAPE: Quantity<number[]>;
34
+ export declare const ANSI_B_LANDSCAPE: Quantity<number[]>;
35
+ export declare const ANSI_C_LANDSCAPE: Quantity<number[]>;
36
+ export declare const ANSI_D_LANDSCAPE: Quantity<number[]>;
37
+ export declare const ANSI_E_LANDSCAPE: Quantity<number[]>;
38
+ export declare const US_ARCH_A: Quantity<number[]>;
39
+ export declare const US_ARCH_B: Quantity<number[]>;
40
+ export declare const US_ARCH_C: Quantity<number[]>;
41
+ export declare const US_ARCH_D: Quantity<number[]>;
42
+ export declare const US_ARCH_E: Quantity<number[]>;
43
+ export declare const US_ARCH_E1: Quantity<number[]>;
44
+ export declare const US_ARCH_E2: Quantity<number[]>;
45
+ export declare const US_ARCH_E3: Quantity<number[]>;
46
+ export declare const US_ARCH_A_LANDSCAPE: Quantity<number[]>;
47
+ export declare const US_ARCH_B_LANDSCAPE: Quantity<number[]>;
48
+ export declare const US_ARCH_C_LANDSCAPE: Quantity<number[]>;
49
+ export declare const US_ARCH_D_LANDSCAPE: Quantity<number[]>;
50
+ export declare const US_ARCH_E_LANDSCAPE: Quantity<number[]>;
51
+ export declare const US_ARCH_E1_LANDSCAPE: Quantity<number[]>;
52
+ export declare const US_ARCH_E2_LANDSCAPE: Quantity<number[]>;
53
+ export declare const US_ARCH_E3_LANDSCAPE: Quantity<number[]>;
54
+ //# sourceMappingURL=paper-sizes.d.ts.map
@@ -0,0 +1,62 @@
1
+ import { Quantity, quantity } from "../unit.js";
2
+ import { inch, mm } from "../units/length.js";
3
+ // https://en.wikipedia.org/wiki/ISO_216x
4
+ export const DIN_A0 = quantity([841, 1189], mm);
5
+ export const DIN_A1 = quantity([594, 841], mm);
6
+ export const DIN_A2 = quantity([420, 594], mm);
7
+ export const DIN_A3 = quantity([297, 420], mm);
8
+ export const DIN_A4 = quantity([210, 297], mm);
9
+ export const DIN_A5 = quantity([148, 210], mm);
10
+ export const DIN_A6 = quantity([105, 148], mm);
11
+ export const DIN_A7 = quantity([74, 105], mm);
12
+ export const DIN_A8 = quantity([52, 74], mm);
13
+ /**
14
+ * Creates a landscape version of given paper size
15
+ *
16
+ * @internal
17
+ */
18
+ const $ = (q) => new Quantity([q.value[1], q.value[0]]);
19
+ export const DIN_A0_LANDSCAPE = $(DIN_A0);
20
+ export const DIN_A1_LANDSCAPE = $(DIN_A1);
21
+ export const DIN_A2_LANDSCAPE = $(DIN_A2);
22
+ export const DIN_A3_LANDSCAPE = $(DIN_A3);
23
+ export const DIN_A4_LANDSCAPE = $(DIN_A4);
24
+ export const DIN_A5_LANDSCAPE = $(DIN_A5);
25
+ export const DIN_A6_LANDSCAPE = $(DIN_A6);
26
+ export const DIN_A7_LANDSCAPE = $(DIN_A7);
27
+ export const DIN_A8_LANDSCAPE = $(DIN_A8);
28
+ // https://papersizes.io/us/
29
+ export const US_LETTER = quantity([8.5, 11], inch);
30
+ export const US_HALF_LETTER = quantity([5.5, 8.5], inch);
31
+ export const US_LEGAL = quantity([8.5, 14], inch);
32
+ export const US_JUNIOR_LEGAL = quantity([5, 8], inch);
33
+ export const US_LETTER_LANDSCAPE = $(US_LETTER);
34
+ export const US_HALF_LETTER_LANDSCAPE = $(US_HALF_LETTER);
35
+ export const US_LEGAL_LANDSCAPE = $(US_LEGAL);
36
+ export const US_JUNIOR_LEGAL_LANDSCAPE = $(US_JUNIOR_LEGAL);
37
+ export const ANSI_A = US_LETTER;
38
+ export const ANSI_B = quantity([11, 17], inch);
39
+ export const ANSI_C = quantity([17, 22], inch);
40
+ export const ANSI_D = quantity([22, 34], inch);
41
+ export const ANSI_E = quantity([34, 44], inch);
42
+ export const ANSI_A_LANDSCAPE = $(ANSI_A);
43
+ export const ANSI_B_LANDSCAPE = $(ANSI_B);
44
+ export const ANSI_C_LANDSCAPE = $(ANSI_C);
45
+ export const ANSI_D_LANDSCAPE = $(ANSI_D);
46
+ export const ANSI_E_LANDSCAPE = $(ANSI_E);
47
+ export const US_ARCH_A = quantity([9, 12], inch);
48
+ export const US_ARCH_B = quantity([12, 18], inch);
49
+ export const US_ARCH_C = quantity([18, 24], inch);
50
+ export const US_ARCH_D = quantity([24, 36], inch);
51
+ export const US_ARCH_E = quantity([36, 48], inch);
52
+ export const US_ARCH_E1 = quantity([30, 42], inch);
53
+ export const US_ARCH_E2 = quantity([26, 38], inch);
54
+ export const US_ARCH_E3 = quantity([27, 39], inch);
55
+ export const US_ARCH_A_LANDSCAPE = $(US_ARCH_A);
56
+ export const US_ARCH_B_LANDSCAPE = $(US_ARCH_B);
57
+ export const US_ARCH_C_LANDSCAPE = $(US_ARCH_C);
58
+ export const US_ARCH_D_LANDSCAPE = $(US_ARCH_D);
59
+ export const US_ARCH_E_LANDSCAPE = $(US_ARCH_E);
60
+ export const US_ARCH_E1_LANDSCAPE = $(US_ARCH_E1);
61
+ export const US_ARCH_E2_LANDSCAPE = $(US_ARCH_E2);
62
+ export const US_ARCH_E3_LANDSCAPE = $(US_ARCH_E3);
package/index.d.ts CHANGED
@@ -21,7 +21,7 @@ export * from "./units/time.js";
21
21
  export * from "./units/velocity.js";
22
22
  export * from "./units/volume.js";
23
23
  export * from "./constants/densities.js";
24
- export * from "./constants/din-sizes.js";
25
24
  export * from "./constants/earth.js";
25
+ export * from "./constants/paper-sizes.js";
26
26
  export * from "./constants/velocities.js";
27
27
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -21,6 +21,6 @@ export * from "./units/time.js";
21
21
  export * from "./units/velocity.js";
22
22
  export * from "./units/volume.js";
23
23
  export * from "./constants/densities.js";
24
- export * from "./constants/din-sizes.js";
25
24
  export * from "./constants/earth.js";
25
+ export * from "./constants/paper-sizes.js";
26
26
  export * from "./constants/velocities.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/units",
3
- "version": "0.3.1",
3
+ "version": "0.4.1",
4
4
  "description": "Extensible SI unit creation, conversions, quantities & calculations (incl. ~170 predefined units & constants)",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -25,7 +25,7 @@
25
25
  "license": "Apache-2.0",
26
26
  "scripts": {
27
27
  "build": "yarn clean && tsc --declaration",
28
- "clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc",
28
+ "clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc constants units",
29
29
  "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
30
30
  "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
31
31
  "doc:readme": "yarn doc:stats && tools:readme",
@@ -34,18 +34,18 @@
34
34
  "test": "testament test"
35
35
  },
36
36
  "dependencies": {
37
- "@thi.ng/api": "^8.7.4",
38
- "@thi.ng/checks": "^3.3.10",
39
- "@thi.ng/equiv": "^2.1.20",
40
- "@thi.ng/errors": "^2.2.13"
37
+ "@thi.ng/api": "^8.7.5",
38
+ "@thi.ng/checks": "^3.3.11",
39
+ "@thi.ng/equiv": "^2.1.21",
40
+ "@thi.ng/errors": "^2.2.14"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@microsoft/api-extractor": "^7.34.4",
44
- "@thi.ng/testament": "^0.3.13",
45
- "rimraf": "^4.4.0",
44
+ "@thi.ng/testament": "^0.3.14",
45
+ "rimraf": "^4.4.1",
46
46
  "tools": "^0.0.1",
47
- "typedoc": "^0.23.26",
48
- "typescript": "^4.9.5"
47
+ "typedoc": "^0.23.28",
48
+ "typescript": "^5.0.2"
49
49
  },
50
50
  "keywords": [
51
51
  "acceleration",
@@ -102,12 +102,12 @@
102
102
  "./constants/densities": {
103
103
  "default": "./constants/densities.js"
104
104
  },
105
- "./constants/din-sizes": {
106
- "default": "./constants/din-sizes.js"
107
- },
108
105
  "./constants/earth": {
109
106
  "default": "./constants/earth.js"
110
107
  },
108
+ "./constants/paper-sizes": {
109
+ "default": "./constants/paper-sizes.js"
110
+ },
111
111
  "./constants/velocities": {
112
112
  "default": "./constants/velocities.js"
113
113
  },
@@ -179,5 +179,5 @@
179
179
  "status": "beta",
180
180
  "year": 2021
181
181
  },
182
- "gitHead": "f493d89d81d450ca67adf4f574b08840cba87807\n"
182
+ "gitHead": "83b15b34326d480cbca0472b20390d4d3bbb792a\n"
183
183
  }
package/unit.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { IDeref } from "@thi.ng/api";
2
- import { Dimensions, MaybeUnit, NamedUnit, Prefix, Unit } from "./api.js";
2
+ import { type Dimensions, type MaybeUnit, type NamedUnit, type Prefix, type Unit } from "./api.js";
3
3
  /**
4
4
  * Cache/registry for all units defined via {@link defUnit}.
5
5
  */
@@ -1,10 +0,0 @@
1
- export declare const DIN_A0: import("../unit.js").Quantity<number[]>;
2
- export declare const DIN_A1: import("../unit.js").Quantity<number[]>;
3
- export declare const DIN_A2: import("../unit.js").Quantity<number[]>;
4
- export declare const DIN_A3: import("../unit.js").Quantity<number[]>;
5
- export declare const DIN_A4: import("../unit.js").Quantity<number[]>;
6
- export declare const DIN_A5: import("../unit.js").Quantity<number[]>;
7
- export declare const DIN_A6: import("../unit.js").Quantity<number[]>;
8
- export declare const DIN_A7: import("../unit.js").Quantity<number[]>;
9
- export declare const DIN_A8: import("../unit.js").Quantity<number[]>;
10
- //# sourceMappingURL=din-sizes.d.ts.map
@@ -1,12 +0,0 @@
1
- import { mm } from "../units/length.js";
2
- import { quantity } from "../unit.js";
3
- // https://en.wikipedia.org/wiki/ISO_216x
4
- export const DIN_A0 = quantity([841, 1189], mm);
5
- export const DIN_A1 = quantity([594, 841], mm);
6
- export const DIN_A2 = quantity([420, 594], mm);
7
- export const DIN_A3 = quantity([297, 420], mm);
8
- export const DIN_A4 = quantity([210, 297], mm);
9
- export const DIN_A5 = quantity([148, 210], mm);
10
- export const DIN_A6 = quantity([105, 148], mm);
11
- export const DIN_A7 = quantity([74, 105], mm);
12
- export const DIN_A8 = quantity([52, 74], mm);
@@ -1,10 +0,0 @@
1
- export declare const DIN_A0: import("../unit.js").Value<number[]>;
2
- export declare const DIN_A1: import("../unit.js").Value<number[]>;
3
- export declare const DIN_A2: import("../unit.js").Value<number[]>;
4
- export declare const DIN_A3: import("../unit.js").Value<number[]>;
5
- export declare const DIN_A4: import("../unit.js").Value<number[]>;
6
- export declare const DIN_A5: import("../unit.js").Value<number[]>;
7
- export declare const DIN_A6: import("../unit.js").Value<number[]>;
8
- export declare const DIN_A7: import("../unit.js").Value<number[]>;
9
- export declare const DIN_A8: import("../unit.js").Value<number[]>;
10
- //# sourceMappingURL=din.d.ts.map
package/constants/din.js DELETED
@@ -1,11 +0,0 @@
1
- import { mm } from "../length.js";
2
- import { value } from "../unit.js";
3
- export const DIN_A0 = value([841, 1189], mm);
4
- export const DIN_A1 = value([594, 841], mm);
5
- export const DIN_A2 = value([420, 594], mm);
6
- export const DIN_A3 = value([297, 420], mm);
7
- export const DIN_A4 = value([210, 297], mm);
8
- export const DIN_A5 = value([148, 210], mm);
9
- export const DIN_A6 = value([105, 148], mm);
10
- export const DIN_A7 = value([74, 105], mm);
11
- export const DIN_A8 = value([52, 74], mm);
package/units/speed.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export declare const m_s: import("../api.js").NamedUnit;
2
- export declare const km_h: import("../api.js").NamedUnit;
3
- export declare const ft_s: import("../api.js").NamedUnit;
4
- export declare const mph: import("../api.js").NamedUnit;
5
- export declare const kn: import("../api.js").NamedUnit;
6
- //# sourceMappingURL=speed.d.ts.map
package/units/speed.js DELETED
@@ -1,8 +0,0 @@
1
- import { defUnit, div } from "../unit.js";
2
- import { ft, km, m, mi, nmi } from "./length.js";
3
- import { h, s } from "./time.js";
4
- export const m_s = defUnit("m/s", "meter per second", div(m, s));
5
- export const km_h = defUnit("km/h", "kilometer per hour", div(km, h));
6
- export const ft_s = defUnit("ft/s", "foot per second", div(ft, s));
7
- export const mph = defUnit("mph", "mile per hour", div(mi, h));
8
- export const kn = defUnit("kn", "knot", div(nmi, h));