@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 +1 -1
- package/README.md +1 -1
- package/api.js +33 -37
- package/constants/densities.js +44 -26
- package/constants/earth.js +15 -32
- package/constants/paper-sizes.js +106 -59
- package/constants/velocities.js +8 -12
- package/package.json +10 -8
- package/unit.js +155 -284
- package/units/accel.js +14 -4
- package/units/angle.js +16 -7
- package/units/area.js +20 -9
- package/units/data.js +50 -25
- package/units/density.js +6 -2
- package/units/electric.js +48 -24
- package/units/energy.js +14 -6
- package/units/force.js +4 -1
- package/units/frequency.js +18 -8
- package/units/length.js +40 -19
- package/units/luminous.js +8 -3
- package/units/mass.js +22 -10
- package/units/parts.js +16 -7
- package/units/power.js +18 -8
- package/units/pressure.js +18 -8
- package/units/substance.js +4 -1
- package/units/temperature.js +12 -3
- package/units/time.js +22 -10
- package/units/velocity.js +12 -5
- package/units/volume.js +34 -14
package/units/electric.js
CHANGED
|
@@ -2,27 +2,51 @@ import { m2 } from "./area.js";
|
|
|
2
2
|
import { J } from "./energy.js";
|
|
3
3
|
import { h, s } from "./time.js";
|
|
4
4
|
import { coherent, defUnit, div, mul, prefix } from "../unit.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export
|
|
5
|
+
const A = defUnit("A", "ampere", coherent(3));
|
|
6
|
+
const mA = defUnit("mA", "milliampere", prefix("m", A));
|
|
7
|
+
const mAh = defUnit("mAh", "milliampere-hour", mul(mA, h));
|
|
8
|
+
const C = defUnit("C", "coulomb", mul(A, s, true));
|
|
9
|
+
const V = defUnit("V", "volt", div(J, C, true));
|
|
10
|
+
const mV = defUnit("mV", "millivolt", prefix("m", V));
|
|
11
|
+
const kV = defUnit("kV", "kilovolt", prefix("k", V));
|
|
12
|
+
const MV = defUnit("MV", "megavolt", prefix("M", V));
|
|
13
|
+
const F = defUnit("F", "farad", div(C, V, true));
|
|
14
|
+
const pF = defUnit("pF", "picofarad", prefix("p", F));
|
|
15
|
+
const \u00B5F = defUnit("\xB5F", "microfarad", prefix("\xB5", F));
|
|
16
|
+
const \u03A9 = defUnit("\u03A9", "ohm", div(V, A, true));
|
|
17
|
+
const k\u03A9 = defUnit("k\u03A9", "kiloohm", prefix("k", \u03A9));
|
|
18
|
+
const M\u03A9 = defUnit("M\u03A9", "megaohm", prefix("M", \u03A9));
|
|
19
|
+
const G\u03A9 = defUnit("G\u03A9", "gigaohm", prefix("G", \u03A9));
|
|
20
|
+
const ohm = \u03A9;
|
|
21
|
+
const kohm = k\u03A9;
|
|
22
|
+
const Mohm = M\u03A9;
|
|
23
|
+
const Gohm = G\u03A9;
|
|
24
|
+
const S = defUnit("S", "siemens", div(A, V, true));
|
|
25
|
+
const Wb = defUnit("Wb", "weber", mul(V, s, true));
|
|
26
|
+
const T = defUnit("T", "tesla", div(Wb, m2, true));
|
|
27
|
+
const H = defUnit("H", "henry", div(Wb, A, true));
|
|
28
|
+
export {
|
|
29
|
+
A,
|
|
30
|
+
C,
|
|
31
|
+
F,
|
|
32
|
+
Gohm,
|
|
33
|
+
G\u03A9,
|
|
34
|
+
H,
|
|
35
|
+
MV,
|
|
36
|
+
Mohm,
|
|
37
|
+
M\u03A9,
|
|
38
|
+
S,
|
|
39
|
+
T,
|
|
40
|
+
V,
|
|
41
|
+
Wb,
|
|
42
|
+
kV,
|
|
43
|
+
kohm,
|
|
44
|
+
k\u03A9,
|
|
45
|
+
mA,
|
|
46
|
+
mAh,
|
|
47
|
+
mV,
|
|
48
|
+
ohm,
|
|
49
|
+
pF,
|
|
50
|
+
\u00B5F,
|
|
51
|
+
\u03A9
|
|
52
|
+
};
|
package/units/energy.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { N } from "./force.js";
|
|
2
2
|
import { m } from "./length.js";
|
|
3
3
|
import { defUnit, mul, prefix } from "../unit.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
const J = defUnit("J", "joule", mul(N, m, true));
|
|
5
|
+
const kJ = defUnit("kJ", "kilojoule", prefix("k", J));
|
|
6
|
+
const MJ = defUnit("MJ", "megajoule", prefix("M", J));
|
|
7
|
+
const GJ = defUnit("GJ", "gigajoule", prefix("G", J));
|
|
8
|
+
const cal = defUnit("cal", "calorie", mul(J, 4.184, true));
|
|
9
|
+
const kcal = defUnit("kcal", "kilocalorie", prefix("k", cal));
|
|
10
|
+
export {
|
|
11
|
+
GJ,
|
|
12
|
+
J,
|
|
13
|
+
MJ,
|
|
14
|
+
cal,
|
|
15
|
+
kJ,
|
|
16
|
+
kcal
|
|
17
|
+
};
|
package/units/force.js
CHANGED
package/units/frequency.js
CHANGED
|
@@ -1,10 +1,20 @@
|
|
|
1
1
|
import { s } from "./time.js";
|
|
2
2
|
import { defUnit, div, mul, prefix, reciprocal } from "../unit.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
const Hz = defUnit("Hz", "hertz", reciprocal(s, true));
|
|
4
|
+
const kHz = defUnit("kHz", "kilohertz", prefix("k", Hz));
|
|
5
|
+
const MHz = defUnit("MHz", "megahertz", prefix("M", Hz));
|
|
6
|
+
const GHz = defUnit("GHz", "gigahertz", prefix("G", Hz));
|
|
7
|
+
const THz = defUnit("THz", "terahertz", prefix("T", Hz));
|
|
8
|
+
const rpm = defUnit("rpm", "rotation per minute", mul(Hz, 1 / 60));
|
|
9
|
+
const \u03C9 = defUnit("\u03C9", "radian per second", div(Hz, 2 * Math.PI));
|
|
10
|
+
const omega = \u03C9;
|
|
11
|
+
export {
|
|
12
|
+
GHz,
|
|
13
|
+
Hz,
|
|
14
|
+
MHz,
|
|
15
|
+
THz,
|
|
16
|
+
kHz,
|
|
17
|
+
omega,
|
|
18
|
+
rpm,
|
|
19
|
+
\u03C9
|
|
20
|
+
};
|
package/units/length.js
CHANGED
|
@@ -1,20 +1,41 @@
|
|
|
1
1
|
import { coherent, defUnit, mul, prefix } from "../unit.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
2
|
+
const m = defUnit("m", "meter", coherent(1));
|
|
3
|
+
const km = defUnit("km", "kilometer", prefix("k", m));
|
|
4
|
+
const cm = defUnit("cm", "centimeter", prefix("c", m));
|
|
5
|
+
const mm = defUnit("mm", "millimeter", prefix("m", m));
|
|
6
|
+
const \u00B5m = defUnit("\xB5m", "micrometer", prefix("\xB5", m));
|
|
7
|
+
const nm = defUnit("nm", "nanometer", prefix("n", m));
|
|
8
|
+
const angstrom = defUnit("\xC5", "angstrom", mul(m, 1e-10));
|
|
9
|
+
const au = defUnit("au", "astronomical unit", mul(m, 149597870700));
|
|
10
|
+
const ly = defUnit("ly", "light year", mul(m, 9460730472580800));
|
|
11
|
+
const pc = defUnit("pc", "parsec", mul(au, 180 * 60 * 60 / Math.PI));
|
|
12
|
+
const inch = defUnit("in", "inch", mul(m, 0.0254));
|
|
13
|
+
const mil = defUnit("mil", "mil", mul(inch, 1e-3));
|
|
14
|
+
const thou = mil;
|
|
15
|
+
const ft = defUnit("ft", "foot", mul(inch, 12));
|
|
16
|
+
const yd = defUnit("yd", "yard", mul(ft, 3));
|
|
17
|
+
const mi = defUnit("mi", "mile", mul(yd, 1760));
|
|
18
|
+
const nmi = defUnit("nmi", "nautical mile", mul(m, 1852));
|
|
19
|
+
const pica = defUnit("pica", "pica", mul(inch, 1 / 6));
|
|
20
|
+
const point = defUnit("point", "point", mul(inch, 1 / 72));
|
|
21
|
+
export {
|
|
22
|
+
angstrom,
|
|
23
|
+
au,
|
|
24
|
+
cm,
|
|
25
|
+
ft,
|
|
26
|
+
inch,
|
|
27
|
+
km,
|
|
28
|
+
ly,
|
|
29
|
+
m,
|
|
30
|
+
mi,
|
|
31
|
+
mil,
|
|
32
|
+
mm,
|
|
33
|
+
nm,
|
|
34
|
+
nmi,
|
|
35
|
+
pc,
|
|
36
|
+
pica,
|
|
37
|
+
point,
|
|
38
|
+
thou,
|
|
39
|
+
yd,
|
|
40
|
+
\u00B5m
|
|
41
|
+
};
|
package/units/luminous.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { sr } from "./angle.js";
|
|
2
2
|
import { m2 } from "./area.js";
|
|
3
3
|
import { coherent, defUnit, div, mul } from "../unit.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const cd = defUnit("cd", "candela", coherent(6));
|
|
5
|
+
const lm = defUnit("lm", "lumen", mul(cd, sr));
|
|
6
|
+
const lx = defUnit("lx", "lux", div(lm, m2));
|
|
7
|
+
export {
|
|
8
|
+
cd,
|
|
9
|
+
lm,
|
|
10
|
+
lx
|
|
11
|
+
};
|
package/units/mass.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { defUnit, mul, prefix, unit } from "../unit.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
const g = defUnit("g", "gram", unit(0, 1e-3, 0, true));
|
|
3
|
+
const kg = defUnit("kg", "kilogram", prefix("k", g));
|
|
4
|
+
const mg = defUnit("mg", "milligram", prefix("m", g));
|
|
5
|
+
const \u00B5g = defUnit("\xB5g", "microgram", prefix("\xB5", g));
|
|
6
|
+
const t = defUnit("t", "tonne", prefix("M", g, true));
|
|
7
|
+
const kt = defUnit("kt", "kilotonne", prefix("k", t));
|
|
8
|
+
const Mt = defUnit("Mt", "megatonne", prefix("M", t));
|
|
9
|
+
const Gt = defUnit("Gt", "gigatonne", prefix("G", t));
|
|
10
|
+
const lb = defUnit("lb", "imperial pound", mul(kg, 0.45359237));
|
|
11
|
+
const st = defUnit("st", "stone", mul(lb, 14));
|
|
12
|
+
export {
|
|
13
|
+
Gt,
|
|
14
|
+
Mt,
|
|
15
|
+
g,
|
|
16
|
+
kg,
|
|
17
|
+
kt,
|
|
18
|
+
lb,
|
|
19
|
+
mg,
|
|
20
|
+
st,
|
|
21
|
+
t,
|
|
22
|
+
\u00B5g
|
|
23
|
+
};
|
package/units/parts.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
1
|
import { defUnit, dimensionless } from "../unit.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
const percent = defUnit("%", "percent", dimensionless(0.01));
|
|
3
|
+
const permille = defUnit("\u2030", "permille", dimensionless(1e-3));
|
|
4
|
+
const permyriad = defUnit("\u2031", "permyriad", dimensionless(1e-4));
|
|
5
|
+
const pcm = defUnit("pcm", "part per cent mille", dimensionless(1e-5));
|
|
6
|
+
const ppm = defUnit("ppm", "part per million", dimensionless(1e-6));
|
|
7
|
+
const ppb = defUnit("ppb", "part per billion", dimensionless(1e-9));
|
|
8
|
+
const ppt = defUnit("ppt", "part per trillion", dimensionless(1e-12));
|
|
9
|
+
export {
|
|
10
|
+
pcm,
|
|
11
|
+
percent,
|
|
12
|
+
permille,
|
|
13
|
+
permyriad,
|
|
14
|
+
ppb,
|
|
15
|
+
ppm,
|
|
16
|
+
ppt
|
|
17
|
+
};
|
package/units/power.js
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { J } from "./energy.js";
|
|
2
2
|
import { h, s } from "./time.js";
|
|
3
3
|
import { defUnit, div, mul, prefix } from "../unit.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const W = defUnit("W", "watt", div(J, s, true));
|
|
5
|
+
const mW = defUnit("mW", "milliwatt", prefix("m", W));
|
|
6
|
+
const kW = defUnit("kW", "kilowatt", prefix("k", W));
|
|
7
|
+
const MW = defUnit("MW", "megawatt", prefix("M", W));
|
|
8
|
+
const GW = defUnit("GW", "gigawatt", prefix("G", W));
|
|
9
|
+
const TW = defUnit("TW", "terawatt", prefix("T", W));
|
|
10
|
+
const Wh = defUnit("Wh", "watt-hour", mul(W, h, true));
|
|
11
|
+
const kWh = defUnit("kWh", "kilowatt-hour", prefix("k", Wh));
|
|
12
|
+
export {
|
|
13
|
+
GW,
|
|
14
|
+
MW,
|
|
15
|
+
TW,
|
|
16
|
+
W,
|
|
17
|
+
Wh,
|
|
18
|
+
kW,
|
|
19
|
+
kWh,
|
|
20
|
+
mW
|
|
21
|
+
};
|
package/units/pressure.js
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { m2 } from "./area.js";
|
|
2
2
|
import { N } from "./force.js";
|
|
3
3
|
import { defUnit, div, mul, prefix } from "../unit.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
const Pa = defUnit("Pa", "pascal", div(N, m2, true));
|
|
5
|
+
const kPa = defUnit("kPa", "kilopascal", prefix("k", Pa));
|
|
6
|
+
const MPa = defUnit("MPa", "megapascal", prefix("M", Pa));
|
|
7
|
+
const GPa = defUnit("GPa", "gigapascal", prefix("G", Pa));
|
|
8
|
+
const at = defUnit("at", "technical atmosphere", mul(Pa, 98066.5));
|
|
9
|
+
const atm = defUnit("atm", "atmosphere", mul(Pa, 101325));
|
|
10
|
+
const bar = defUnit("bar", "bar", mul(Pa, 1e5, true));
|
|
11
|
+
const psi = defUnit("psi", "pound per square inch", mul(Pa, 6894.757));
|
|
12
|
+
export {
|
|
13
|
+
GPa,
|
|
14
|
+
MPa,
|
|
15
|
+
Pa,
|
|
16
|
+
at,
|
|
17
|
+
atm,
|
|
18
|
+
bar,
|
|
19
|
+
kPa,
|
|
20
|
+
psi
|
|
21
|
+
};
|
package/units/substance.js
CHANGED
package/units/temperature.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import { coherent, defUnit, unit } from "../unit.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
const K = defUnit("K", "kelvin", coherent(4));
|
|
3
|
+
const celsius = defUnit("\u2103", "degree celsius", unit(4, 1, 273.15));
|
|
4
|
+
const fahrenheit = defUnit(
|
|
5
|
+
"\u2109",
|
|
6
|
+
"degree fahrenheit",
|
|
7
|
+
unit(4, 1 / 1.8, 459.67 / 1.8)
|
|
8
|
+
);
|
|
9
|
+
export {
|
|
10
|
+
K,
|
|
11
|
+
celsius,
|
|
12
|
+
fahrenheit
|
|
13
|
+
};
|
package/units/time.js
CHANGED
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
import { coherent, defUnit, mul, prefix } from "../unit.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
const s = defUnit("s", "second", coherent(2));
|
|
3
|
+
const ms = defUnit("ms", "millisecond", prefix("m", s));
|
|
4
|
+
const \u00B5s = defUnit("\xB5s", "microsecond", prefix("\xB5", s));
|
|
5
|
+
const ns = defUnit("ns", "nanosecond", prefix("n", s));
|
|
6
|
+
const min = defUnit("min", "minute", mul(s, 60));
|
|
7
|
+
const h = defUnit("h", "hour", mul(min, 60));
|
|
8
|
+
const d = defUnit("day", "day", mul(h, 24));
|
|
9
|
+
const week = defUnit("week", "week", mul(d, 7));
|
|
10
|
+
const month = defUnit("month", "month", mul(d, 30));
|
|
11
|
+
const year = defUnit("year", "year", mul(d, 365.25));
|
|
12
|
+
export {
|
|
13
|
+
d,
|
|
14
|
+
h,
|
|
15
|
+
min,
|
|
16
|
+
month,
|
|
17
|
+
ms,
|
|
18
|
+
ns,
|
|
19
|
+
s,
|
|
20
|
+
week,
|
|
21
|
+
year,
|
|
22
|
+
\u00B5s
|
|
23
|
+
};
|
package/units/velocity.js
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { defUnit, div } from "../unit.js";
|
|
2
2
|
import { ft, km, m, mi, nmi } from "./length.js";
|
|
3
3
|
import { h, s } from "./time.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
const m_s = defUnit("m/s", "meter per second", div(m, s));
|
|
5
|
+
const km_h = defUnit("km/h", "kilometer per hour", div(km, h));
|
|
6
|
+
const ft_s = defUnit("ft/s", "foot per second", div(ft, s));
|
|
7
|
+
const mph = defUnit("mph", "mile per hour", div(mi, h));
|
|
8
|
+
const kn = defUnit("kn", "knot", div(nmi, h));
|
|
9
|
+
export {
|
|
10
|
+
ft_s,
|
|
11
|
+
km_h,
|
|
12
|
+
kn,
|
|
13
|
+
m_s,
|
|
14
|
+
mph
|
|
15
|
+
};
|
package/units/volume.js
CHANGED
|
@@ -1,16 +1,36 @@
|
|
|
1
1
|
import { cm, km, m, mm } from "./length.js";
|
|
2
2
|
import { defUnit, mul, pow, prefix } from "../unit.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
3
|
+
const m3 = defUnit("m3", "cubic meter", pow(m, 3));
|
|
4
|
+
const mm3 = defUnit("mm3", "cubic millimeter", pow(mm, 3));
|
|
5
|
+
const cm3 = defUnit("cm3", "cubic centimeter", pow(cm, 3));
|
|
6
|
+
const km3 = defUnit("km3", "cubic kilometer", pow(km, 3));
|
|
7
|
+
const l = defUnit("l", "liter", mul(m3, 1e-3, true));
|
|
8
|
+
const cl = defUnit("cl", "centiliter", prefix("c", l));
|
|
9
|
+
const ml = defUnit("ml", "milliliter", prefix("m", l));
|
|
10
|
+
const gal = defUnit("gal", "imperial gallon", mul(l, 4.54609));
|
|
11
|
+
const pt = defUnit("pt", "imperial pint", mul(gal, 1 / 8));
|
|
12
|
+
const floz = defUnit("fl oz", "imperial fluid ounce", mul(gal, 1 / 160));
|
|
13
|
+
const us_gal = defUnit("us gal", "us gallon", mul(l, 3.785411784));
|
|
14
|
+
const us_pt = defUnit("us pt", "us pint", mul(us_gal, 1 / 8));
|
|
15
|
+
const us_cup = defUnit("us cup", "us cup", mul(us_gal, 1 / 16));
|
|
16
|
+
const us_floz = defUnit(
|
|
17
|
+
"us fl oz",
|
|
18
|
+
"us fluid ounce",
|
|
19
|
+
mul(us_gal, 1 / 128)
|
|
20
|
+
);
|
|
21
|
+
export {
|
|
22
|
+
cl,
|
|
23
|
+
cm3,
|
|
24
|
+
floz,
|
|
25
|
+
gal,
|
|
26
|
+
km3,
|
|
27
|
+
l,
|
|
28
|
+
m3,
|
|
29
|
+
ml,
|
|
30
|
+
mm3,
|
|
31
|
+
pt,
|
|
32
|
+
us_cup,
|
|
33
|
+
us_floz,
|
|
34
|
+
us_gal,
|
|
35
|
+
us_pt
|
|
36
|
+
};
|