@thi.ng/units 0.4.17 → 0.4.19

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-12-03T12:13:31Z
3
+ - **Last updated**: 2023-12-11T10:07:09Z
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.
package/README.md CHANGED
@@ -616,7 +616,7 @@ For Node.js REPL:
616
616
  const units = await import("@thi.ng/units");
617
617
  ```
618
618
 
619
- Package sizes (brotli'd, pre-treeshake): ESM: 4.86 KB
619
+ Package sizes (brotli'd, pre-treeshake): ESM: 4.77 KB
620
620
 
621
621
  ## Dependencies
622
622
 
package/api.js CHANGED
@@ -1,39 +1,35 @@
1
- /**
2
- * @remarks
3
- * Reference:
4
- * - https://en.wikipedia.org/wiki/Metric_prefix
5
- */
6
- export const PREFIXES = {
7
- Q: 1e30,
8
- R: 1e27,
9
- Y: 1e24,
10
- Z: 1e21,
11
- E: 1e18,
12
- P: 1e15,
13
- T: 1e12,
14
- G: 1e9,
15
- M: 1e6,
16
- k: 1e3,
17
- h: 1e2,
18
- d: 1e-1,
19
- c: 1e-2,
20
- m: 1e-3,
21
- µ: 1e-6,
22
- n: 1e-9,
23
- p: 1e-12,
24
- f: 1e-15,
25
- a: 1e-18,
26
- z: 1e-21,
27
- y: 1e-24,
28
- r: 1e-27,
29
- q: 1e-30,
1
+ const PREFIXES = {
2
+ Q: 1e30,
3
+ R: 1e27,
4
+ Y: 1e24,
5
+ Z: 1e21,
6
+ E: 1e18,
7
+ P: 1e15,
8
+ T: 1e12,
9
+ G: 1e9,
10
+ M: 1e6,
11
+ k: 1e3,
12
+ h: 100,
13
+ d: 0.1,
14
+ c: 0.01,
15
+ m: 1e-3,
16
+ \u00B5: 1e-6,
17
+ n: 1e-9,
18
+ p: 1e-12,
19
+ f: 1e-15,
20
+ a: 1e-18,
21
+ z: 1e-21,
22
+ y: 1e-24,
23
+ r: 1e-27,
24
+ q: 1e-30
30
25
  };
31
- /**
32
- * Dimensionless unit preset.
33
- */
34
- export const NONE = {
35
- dim: [0, 0, 0, 0, 0, 0, 0],
36
- scale: 1,
37
- offset: 0,
38
- coherent: false,
26
+ const NONE = {
27
+ dim: [0, 0, 0, 0, 0, 0, 0],
28
+ scale: 1,
29
+ offset: 0,
30
+ coherent: false
31
+ };
32
+ export {
33
+ NONE,
34
+ PREFIXES
39
35
  };
@@ -1,28 +1,46 @@
1
1
  import { quantity } from "../unit.js";
2
2
  import { kg_m3 } from "../units/density.js";
3
- // https://en.wikipedia.org/wiki/Density#Various_materials
4
- export const AIR = quantity(1.2, kg_m3);
5
- export const ALUMINIUM = quantity(2700, kg_m3);
6
- // for americans...
7
- export const ALUMINUM = ALUMINIUM;
8
- export const CONCRETE = quantity(2400, kg_m3);
9
- export const COPPER = quantity(8940, kg_m3);
10
- export const DIAMOND = quantity(3500, kg_m3);
11
- export const GLASS = quantity(2500, kg_m3);
12
- export const GOLD = quantity(19320, kg_m3);
13
- export const ICE = quantity(916.7, kg_m3);
14
- export const IRON = quantity(7870, kg_m3);
15
- export const NYLON = quantity(1150, kg_m3);
16
- export const PLASTIC = quantity(1175, kg_m3);
17
- export const PLATINUM = quantity(21450, kg_m3);
18
- export const SAND = quantity(1600, kg_m3);
19
- export const SALT_WATER = quantity(1030, kg_m3);
20
- export const SILICON = quantity(2330, kg_m3);
21
- export const SILVER = quantity(10500, kg_m3);
22
- export const STEEL = quantity(7850, kg_m3);
23
- export const TITANIUM = quantity(4540, kg_m3);
24
- /**
25
- * Fresh water @ 4 degree celsius (max. density)
26
- */
27
- export const WATER = quantity(1000, kg_m3);
28
- export const WOOD = quantity(700, kg_m3);
3
+ const AIR = quantity(1.2, kg_m3);
4
+ const ALUMINIUM = quantity(2700, kg_m3);
5
+ const ALUMINUM = ALUMINIUM;
6
+ const CONCRETE = quantity(2400, kg_m3);
7
+ const COPPER = quantity(8940, kg_m3);
8
+ const DIAMOND = quantity(3500, kg_m3);
9
+ const GLASS = quantity(2500, kg_m3);
10
+ const GOLD = quantity(19320, kg_m3);
11
+ const ICE = quantity(916.7, kg_m3);
12
+ const IRON = quantity(7870, kg_m3);
13
+ const NYLON = quantity(1150, kg_m3);
14
+ const PLASTIC = quantity(1175, kg_m3);
15
+ const PLATINUM = quantity(21450, kg_m3);
16
+ const SAND = quantity(1600, kg_m3);
17
+ const SALT_WATER = quantity(1030, kg_m3);
18
+ const SILICON = quantity(2330, kg_m3);
19
+ const SILVER = quantity(10500, kg_m3);
20
+ const STEEL = quantity(7850, kg_m3);
21
+ const TITANIUM = quantity(4540, kg_m3);
22
+ const WATER = quantity(1e3, kg_m3);
23
+ const WOOD = quantity(700, kg_m3);
24
+ export {
25
+ AIR,
26
+ ALUMINIUM,
27
+ ALUMINUM,
28
+ CONCRETE,
29
+ COPPER,
30
+ DIAMOND,
31
+ GLASS,
32
+ GOLD,
33
+ ICE,
34
+ IRON,
35
+ NYLON,
36
+ PLASTIC,
37
+ PLATINUM,
38
+ SALT_WATER,
39
+ SAND,
40
+ SILICON,
41
+ SILVER,
42
+ STEEL,
43
+ TITANIUM,
44
+ WATER,
45
+ WOOD
46
+ };
@@ -1,35 +1,18 @@
1
1
  import { quantity, unit } from "../unit.js";
2
2
  import { m_s2 } from "../units/accel.js";
3
3
  import { m } from "../units/length.js";
4
- /**
5
- * https://en.wikipedia.org/wiki/Earth_radius
6
- */
7
- export const EARTH_RADIUS = quantity(6371000, m);
8
- /**
9
- * At equator
10
- *
11
- * @remarks
12
- * Reference:
13
- * - https://en.wikipedia.org/wiki/Earth%27s_circumference
14
- */
15
- export const EARTH_CIRCUMFERENCE = quantity(40075017, m);
16
- /**
17
- * Using equatorial mean as alternative to {@link g0}.
18
- *
19
- * @remarks
20
- * Reference:
21
- * - https://en.wikipedia.org/wiki/Gravity_of_Earth
22
- */
23
- export const EARTH_GRAVITY = quantity(9.78033, m_s2);
24
- /**
25
- * https://nssdc.gsfc.nasa.gov/planetary/factsheet/earthfact.html
26
- */
27
- export const EARTH_MASS = quantity(5.9722e24, "kg");
28
- /**
29
- * Gravitational constant (kg-1·m3·s-2)
30
- *
31
- * @remarks
32
- * Reference:
33
- * - https://en.wikipedia.org/wiki/Gravitational_constant
34
- */
35
- export const GRAVITATION = quantity(6.6743e-11, unit([-1, 3, -2, 0, 0, 0, 0], 1));
4
+ const EARTH_RADIUS = quantity(6371e3, m);
5
+ const EARTH_CIRCUMFERENCE = quantity(40075017, m);
6
+ const EARTH_GRAVITY = quantity(9.78033, m_s2);
7
+ const EARTH_MASS = quantity(59722e20, "kg");
8
+ const GRAVITATION = quantity(
9
+ 66743e-15,
10
+ unit([-1, 3, -2, 0, 0, 0, 0], 1)
11
+ );
12
+ export {
13
+ EARTH_CIRCUMFERENCE,
14
+ EARTH_GRAVITY,
15
+ EARTH_MASS,
16
+ EARTH_RADIUS,
17
+ GRAVITATION
18
+ };
@@ -1,62 +1,109 @@
1
1
  import { Quantity, quantity } from "../unit.js";
2
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
- */
3
+ const DIN_A0 = quantity([841, 1189], mm);
4
+ const DIN_A1 = quantity([594, 841], mm);
5
+ const DIN_A2 = quantity([420, 594], mm);
6
+ const DIN_A3 = quantity([297, 420], mm);
7
+ const DIN_A4 = quantity([210, 297], mm);
8
+ const DIN_A5 = quantity([148, 210], mm);
9
+ const DIN_A6 = quantity([105, 148], mm);
10
+ const DIN_A7 = quantity([74, 105], mm);
11
+ const DIN_A8 = quantity([52, 74], mm);
18
12
  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);
13
+ const DIN_A0_LANDSCAPE = $(DIN_A0);
14
+ const DIN_A1_LANDSCAPE = $(DIN_A1);
15
+ const DIN_A2_LANDSCAPE = $(DIN_A2);
16
+ const DIN_A3_LANDSCAPE = $(DIN_A3);
17
+ const DIN_A4_LANDSCAPE = $(DIN_A4);
18
+ const DIN_A5_LANDSCAPE = $(DIN_A5);
19
+ const DIN_A6_LANDSCAPE = $(DIN_A6);
20
+ const DIN_A7_LANDSCAPE = $(DIN_A7);
21
+ const DIN_A8_LANDSCAPE = $(DIN_A8);
22
+ const US_LETTER = quantity([8.5, 11], inch);
23
+ const US_HALF_LETTER = quantity([5.5, 8.5], inch);
24
+ const US_LEGAL = quantity([8.5, 14], inch);
25
+ const US_JUNIOR_LEGAL = quantity([5, 8], inch);
26
+ const US_LETTER_LANDSCAPE = $(US_LETTER);
27
+ const US_HALF_LETTER_LANDSCAPE = $(US_HALF_LETTER);
28
+ const US_LEGAL_LANDSCAPE = $(US_LEGAL);
29
+ const US_JUNIOR_LEGAL_LANDSCAPE = $(US_JUNIOR_LEGAL);
30
+ const ANSI_A = US_LETTER;
31
+ const ANSI_B = quantity([11, 17], inch);
32
+ const ANSI_C = quantity([17, 22], inch);
33
+ const ANSI_D = quantity([22, 34], inch);
34
+ const ANSI_E = quantity([34, 44], inch);
35
+ const ANSI_A_LANDSCAPE = $(ANSI_A);
36
+ const ANSI_B_LANDSCAPE = $(ANSI_B);
37
+ const ANSI_C_LANDSCAPE = $(ANSI_C);
38
+ const ANSI_D_LANDSCAPE = $(ANSI_D);
39
+ const ANSI_E_LANDSCAPE = $(ANSI_E);
40
+ const US_ARCH_A = quantity([9, 12], inch);
41
+ const US_ARCH_B = quantity([12, 18], inch);
42
+ const US_ARCH_C = quantity([18, 24], inch);
43
+ const US_ARCH_D = quantity([24, 36], inch);
44
+ const US_ARCH_E = quantity([36, 48], inch);
45
+ const US_ARCH_E1 = quantity([30, 42], inch);
46
+ const US_ARCH_E2 = quantity([26, 38], inch);
47
+ const US_ARCH_E3 = quantity([27, 39], inch);
48
+ const US_ARCH_A_LANDSCAPE = $(US_ARCH_A);
49
+ const US_ARCH_B_LANDSCAPE = $(US_ARCH_B);
50
+ const US_ARCH_C_LANDSCAPE = $(US_ARCH_C);
51
+ const US_ARCH_D_LANDSCAPE = $(US_ARCH_D);
52
+ const US_ARCH_E_LANDSCAPE = $(US_ARCH_E);
53
+ const US_ARCH_E1_LANDSCAPE = $(US_ARCH_E1);
54
+ const US_ARCH_E2_LANDSCAPE = $(US_ARCH_E2);
55
+ const US_ARCH_E3_LANDSCAPE = $(US_ARCH_E3);
56
+ export {
57
+ ANSI_A,
58
+ ANSI_A_LANDSCAPE,
59
+ ANSI_B,
60
+ ANSI_B_LANDSCAPE,
61
+ ANSI_C,
62
+ ANSI_C_LANDSCAPE,
63
+ ANSI_D,
64
+ ANSI_D_LANDSCAPE,
65
+ ANSI_E,
66
+ ANSI_E_LANDSCAPE,
67
+ DIN_A0,
68
+ DIN_A0_LANDSCAPE,
69
+ DIN_A1,
70
+ DIN_A1_LANDSCAPE,
71
+ DIN_A2,
72
+ DIN_A2_LANDSCAPE,
73
+ DIN_A3,
74
+ DIN_A3_LANDSCAPE,
75
+ DIN_A4,
76
+ DIN_A4_LANDSCAPE,
77
+ DIN_A5,
78
+ DIN_A5_LANDSCAPE,
79
+ DIN_A6,
80
+ DIN_A6_LANDSCAPE,
81
+ DIN_A7,
82
+ DIN_A7_LANDSCAPE,
83
+ DIN_A8,
84
+ DIN_A8_LANDSCAPE,
85
+ US_ARCH_A,
86
+ US_ARCH_A_LANDSCAPE,
87
+ US_ARCH_B,
88
+ US_ARCH_B_LANDSCAPE,
89
+ US_ARCH_C,
90
+ US_ARCH_C_LANDSCAPE,
91
+ US_ARCH_D,
92
+ US_ARCH_D_LANDSCAPE,
93
+ US_ARCH_E,
94
+ US_ARCH_E1,
95
+ US_ARCH_E1_LANDSCAPE,
96
+ US_ARCH_E2,
97
+ US_ARCH_E2_LANDSCAPE,
98
+ US_ARCH_E3,
99
+ US_ARCH_E3_LANDSCAPE,
100
+ US_ARCH_E_LANDSCAPE,
101
+ US_HALF_LETTER,
102
+ US_HALF_LETTER_LANDSCAPE,
103
+ US_JUNIOR_LEGAL,
104
+ US_JUNIOR_LEGAL_LANDSCAPE,
105
+ US_LEGAL,
106
+ US_LEGAL_LANDSCAPE,
107
+ US_LETTER,
108
+ US_LETTER_LANDSCAPE
109
+ };
@@ -1,14 +1,10 @@
1
1
  import { quantity } from "../unit.js";
2
2
  import { m_s } from "../units/velocity.js";
3
- /**
4
- * https://en.wikipedia.org/wiki/Speed_of_light
5
- */
6
- export const SPEED_OF_LIGHT = quantity(299792458, m_s);
7
- /**
8
- * At 20 degree celsius
9
- */
10
- export const SPEED_OF_SOUND_IN_AIR = quantity(343.14, m_s);
11
- /**
12
- * At 20 degree celsius
13
- */
14
- export const SPEED_OF_SOUND_IN_WATER = quantity(1482, m_s);
3
+ const SPEED_OF_LIGHT = quantity(299792458, m_s);
4
+ const SPEED_OF_SOUND_IN_AIR = quantity(343.14, m_s);
5
+ const SPEED_OF_SOUND_IN_WATER = quantity(1482, m_s);
6
+ export {
7
+ SPEED_OF_LIGHT,
8
+ SPEED_OF_SOUND_IN_AIR,
9
+ SPEED_OF_SOUND_IN_WATER
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/units",
3
- "version": "0.4.17",
3
+ "version": "0.4.19",
4
4
  "description": "Extensible SI unit creation, conversions, quantities & calculations (incl. ~170 predefined units & constants)",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -24,7 +24,9 @@
24
24
  "author": "Karsten Schmidt (https://thi.ng)",
25
25
  "license": "Apache-2.0",
26
26
  "scripts": {
27
- "build": "yarn clean && tsc --declaration",
27
+ "build": "yarn build:esbuild && yarn build:decl",
28
+ "build:decl": "tsc --declaration --emitDeclarationOnly",
29
+ "build:esbuild": "esbuild --format=esm --platform=neutral --target=es2022 --tsconfig=tsconfig.json --outdir=. src/**/*.ts",
28
30
  "clean": "rimraf --glob '*.js' '*.d.ts' '*.map' doc constants units",
29
31
  "doc": "typedoc --excludePrivate --excludeInternal --out doc src/index.ts",
30
32
  "doc:ae": "mkdir -p .ae/doc .ae/temp && api-extractor run --local --verbose",
@@ -33,14 +35,14 @@
33
35
  "test": "bun test"
34
36
  },
35
37
  "dependencies": {
36
- "@thi.ng/api": "^8.9.10",
37
- "@thi.ng/checks": "^3.4.10",
38
- "@thi.ng/equiv": "^2.1.35",
39
- "@thi.ng/errors": "^2.4.4"
38
+ "@thi.ng/api": "^8.9.12",
39
+ "@thi.ng/checks": "^3.4.12",
40
+ "@thi.ng/equiv": "^2.1.37",
41
+ "@thi.ng/errors": "^2.4.6"
40
42
  },
41
43
  "devDependencies": {
42
44
  "@microsoft/api-extractor": "^7.38.3",
43
- "@thi.ng/testament": "^0.4.3",
45
+ "esbuild": "^0.19.8",
44
46
  "rimraf": "^5.0.5",
45
47
  "tools": "^0.0.1",
46
48
  "typedoc": "^0.25.4",
@@ -178,5 +180,5 @@
178
180
  "status": "beta",
179
181
  "year": 2021
180
182
  },
181
- "gitHead": "04d1de79f256d7a53c6b5fd157b37f49bc88e11d\n"
183
+ "gitHead": "5e7bafedfc3d53bc131469a28de31dd8e5b4a3ff\n"
182
184
  }