engineering-unit-converter 0.0.14 → 0.0.15
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/README.md
CHANGED
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
engineering-unit-converter
|
|
2
|
-
=============
|
|
3
|
-
|
|
4
|
-
A light and simple library for make all type measures conversions and manipulations.
|
|
5
|
-
Used [convert-units](https://github.com/ben-ng/convert-units) as a reference.
|
|
6
|
-
|
|
7
|
-
Installation
|
|
8
|
-
-----
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
npm install engineering-unit-converter
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Usage
|
|
15
|
-
-----
|
|
16
|
-
|
|
17
|
-
`engineering-unit-converter` uses TypeScript to infer the available units, I strongly recommend using it for making the dev experience better.
|
|
18
|
-
|
|
19
|
-
Using this library is simple, the above snippet shows an example:
|
|
20
|
-
|
|
21
|
-
```js
|
|
22
|
-
import { massFlow } from 'engineering-unit-converter'
|
|
23
|
-
const newValue = massFlow(65000).from('lb/day').to('kg/h')
|
|
24
|
-
console.log(newValue) //1228.4818798922718
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Available units
|
|
28
|
-
-----
|
|
29
|
-
|
|
30
|
-
- acceleration
|
|
31
|
-
- area
|
|
32
|
-
- density
|
|
33
|
-
- electricCharge
|
|
34
|
-
- electricCurrent
|
|
35
|
-
- energy
|
|
36
|
-
- force
|
|
37
|
-
- length
|
|
38
|
-
- massFlow
|
|
39
|
-
- mass
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
1
|
+
engineering-unit-converter
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
A light and simple library for make all type measures conversions and manipulations.
|
|
5
|
+
Used [convert-units](https://github.com/ben-ng/convert-units) as a reference.
|
|
6
|
+
|
|
7
|
+
Installation
|
|
8
|
+
-----
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install engineering-unit-converter
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Usage
|
|
15
|
+
-----
|
|
16
|
+
|
|
17
|
+
`engineering-unit-converter` uses TypeScript to infer the available units, I strongly recommend using it for making the dev experience better.
|
|
18
|
+
|
|
19
|
+
Using this library is simple, the above snippet shows an example:
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import { massFlow } from 'engineering-unit-converter'
|
|
23
|
+
const newValue = massFlow(65000).from('lb/day').to('kg/h')
|
|
24
|
+
console.log(newValue) //1228.4818798922718
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Available units
|
|
28
|
+
-----
|
|
29
|
+
|
|
30
|
+
- acceleration
|
|
31
|
+
- area
|
|
32
|
+
- density
|
|
33
|
+
- electricCharge
|
|
34
|
+
- electricCurrent
|
|
35
|
+
- energy
|
|
36
|
+
- force
|
|
37
|
+
- length
|
|
38
|
+
- massFlow
|
|
39
|
+
- mass
|
|
40
|
+
- massPerStandardVolume
|
|
41
|
+
- power
|
|
42
|
+
- pressureManometric
|
|
43
|
+
- pressure
|
|
44
|
+
- speed
|
|
45
|
+
- standardVolumetricFlow
|
|
46
|
+
- surfaceTension
|
|
47
|
+
- time
|
|
48
|
+
- viscosity
|
|
49
|
+
- voltage
|
|
50
|
+
- volume
|
|
50
51
|
- volumetricFlow
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var c = (
|
|
1
|
+
var m = Object.defineProperty;
|
|
2
|
+
var l = (r, e, n) => e in r ? m(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
|
+
var c = (r, e, n) => (l(r, typeof e != "symbol" ? e + "" : e, n), n);
|
|
4
4
|
class u {
|
|
5
|
-
constructor(e,
|
|
5
|
+
constructor(e, n) {
|
|
6
6
|
c(this, "_definitions");
|
|
7
7
|
c(this, "_val");
|
|
8
8
|
c(this, "_fromUnit", null);
|
|
9
|
-
this._definitions =
|
|
9
|
+
this._definitions = n, this._val = e;
|
|
10
10
|
}
|
|
11
11
|
from(e) {
|
|
12
12
|
return this._checkUnit(e), this._fromUnit = e, this;
|
|
@@ -15,24 +15,24 @@ class u {
|
|
|
15
15
|
if (!this._fromUnit)
|
|
16
16
|
throw new Error('Please specify the "from" unit using the from() method before calling to().');
|
|
17
17
|
this._checkUnit(e);
|
|
18
|
-
const
|
|
18
|
+
const n = this._getUnit(this._fromUnit), t = this._getUnit(e);
|
|
19
19
|
let o = this._val;
|
|
20
|
-
return
|
|
20
|
+
return n.offset !== 0 && (o -= n.offset), o = o * n.convertValue / t.convertValue, t.offset !== 0 && (o += t.offset), o;
|
|
21
21
|
}
|
|
22
22
|
_getUnit(e) {
|
|
23
|
-
const
|
|
24
|
-
return { convertValue:
|
|
23
|
+
const n = this._definitions.units[e], t = n.offset ?? 0;
|
|
24
|
+
return { convertValue: n.convertValue, offset: t };
|
|
25
25
|
}
|
|
26
26
|
_checkUnit(e) {
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
29
|
-
throw new Error(`Invalid unit "${e}". Available units: ${
|
|
27
|
+
const n = Object.keys(this._definitions.units);
|
|
28
|
+
if (!n.includes(e))
|
|
29
|
+
throw new Error(`Invalid unit "${e}". Available units: ${n.join(", ")}`);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
class s {
|
|
33
|
-
constructor(e,
|
|
33
|
+
constructor(e, n) {
|
|
34
34
|
c(this, "_internalConverter");
|
|
35
|
-
this._internalConverter = new u(e,
|
|
35
|
+
this._internalConverter = new u(e, n);
|
|
36
36
|
}
|
|
37
37
|
from(e) {
|
|
38
38
|
return this._internalConverter.from(e), new i(this._internalConverter);
|
|
@@ -46,7 +46,7 @@ class i {
|
|
|
46
46
|
return this._internalConverter.to(e);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
const
|
|
49
|
+
const a = (r) => (e) => new s(e, r), v = {
|
|
50
50
|
baseUnit: "m/s2",
|
|
51
51
|
units: {
|
|
52
52
|
"m/s2": {
|
|
@@ -66,7 +66,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
66
66
|
convertValue: 1 / 3.28084
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
},
|
|
69
|
+
}, B = a(v), V = {
|
|
70
70
|
baseUnit: "m2",
|
|
71
71
|
units: {
|
|
72
72
|
m2: {
|
|
@@ -114,7 +114,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
114
114
|
// Conversion factor from m2 to hectare
|
|
115
115
|
}
|
|
116
116
|
}
|
|
117
|
-
},
|
|
117
|
+
}, N = a(V), p = {
|
|
118
118
|
baseUnit: "kg/m3",
|
|
119
119
|
units: {
|
|
120
120
|
"kg/m3": {
|
|
@@ -138,7 +138,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
138
138
|
convertValue: 1 / 2.20462
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
},
|
|
141
|
+
}, T = a(p), d = {
|
|
142
142
|
baseUnit: "C",
|
|
143
143
|
units: {
|
|
144
144
|
C: {
|
|
@@ -166,7 +166,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
166
166
|
// Conversion factor from C to pC
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
},
|
|
169
|
+
}, W = a(d), g = {
|
|
170
170
|
baseUnit: "A",
|
|
171
171
|
units: {
|
|
172
172
|
A: {
|
|
@@ -194,7 +194,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
194
194
|
// Conversion factor from A to pA
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
|
-
},
|
|
197
|
+
}, H = a(g), f = {
|
|
198
198
|
baseUnit: "J",
|
|
199
199
|
units: {
|
|
200
200
|
J: {
|
|
@@ -232,7 +232,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
232
232
|
// Conversion factor from J to BTU
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
-
},
|
|
235
|
+
}, J = a(f), h = {
|
|
236
236
|
baseUnit: "N",
|
|
237
237
|
units: {
|
|
238
238
|
N: {
|
|
@@ -255,7 +255,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
255
255
|
// Conversion factor from N to kgf
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
},
|
|
258
|
+
}, L = a(h), b = {
|
|
259
259
|
baseUnit: "m",
|
|
260
260
|
units: {
|
|
261
261
|
m: {
|
|
@@ -295,7 +295,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
295
295
|
convertValue: 1e-9
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
},
|
|
298
|
+
}, O = a(b), C = {
|
|
299
299
|
baseUnit: "kg/s",
|
|
300
300
|
units: {
|
|
301
301
|
"kg/s": {
|
|
@@ -340,7 +340,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
340
340
|
// 1 day = 86400 seconds
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
},
|
|
343
|
+
}, j = a(C), M = {
|
|
344
344
|
baseUnit: "kg",
|
|
345
345
|
units: {
|
|
346
346
|
kg: {
|
|
@@ -372,7 +372,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
372
372
|
convertValue: 1e-6
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
},
|
|
375
|
+
}, z = a(M), S = {
|
|
376
376
|
baseUnit: "W",
|
|
377
377
|
units: {
|
|
378
378
|
W: {
|
|
@@ -400,7 +400,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
400
400
|
// Conversion factor from W to cal/s
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
},
|
|
403
|
+
}, E = a(S), P = {
|
|
404
404
|
baseUnit: "Pag",
|
|
405
405
|
units: {
|
|
406
406
|
Pag: {
|
|
@@ -438,7 +438,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
438
438
|
// Conversion factor from Pa to kg/cm²
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
|
-
},
|
|
441
|
+
}, Y = a(P), k = {
|
|
442
442
|
baseUnit: "Pa",
|
|
443
443
|
units: {
|
|
444
444
|
Pa: {
|
|
@@ -522,7 +522,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
522
522
|
// Conversion factor from Pa to psi
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
|
-
},
|
|
525
|
+
}, x = a(k), K = {
|
|
526
526
|
baseUnit: "m/s",
|
|
527
527
|
units: {
|
|
528
528
|
"m/s": {
|
|
@@ -558,7 +558,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
558
558
|
convertValue: 2.23694
|
|
559
559
|
}
|
|
560
560
|
}
|
|
561
|
-
},
|
|
561
|
+
}, Q = a(K), y = {
|
|
562
562
|
baseUnit: "SCMD",
|
|
563
563
|
units: {
|
|
564
564
|
SCMD: {
|
|
@@ -601,7 +601,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
601
601
|
// Conversion factor from SCMD to MMSCFD
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
|
-
},
|
|
604
|
+
}, R = a(y), F = {
|
|
605
605
|
baseUnit: "N/m",
|
|
606
606
|
units: {
|
|
607
607
|
"N/m": {
|
|
@@ -629,7 +629,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
629
629
|
convertValue: 10.945427
|
|
630
630
|
}
|
|
631
631
|
}
|
|
632
|
-
},
|
|
632
|
+
}, X = a(F), U = {
|
|
633
633
|
baseUnit: "sec",
|
|
634
634
|
units: {
|
|
635
635
|
sec: {
|
|
@@ -662,7 +662,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
662
662
|
// Conversion factor from seconds to days
|
|
663
663
|
}
|
|
664
664
|
}
|
|
665
|
-
},
|
|
665
|
+
}, Z = a(U), q = {
|
|
666
666
|
baseUnit: "cP",
|
|
667
667
|
units: {
|
|
668
668
|
cP: {
|
|
@@ -690,7 +690,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
690
690
|
convertValue: 1 / 3.6
|
|
691
691
|
}
|
|
692
692
|
}
|
|
693
|
-
},
|
|
693
|
+
}, ee = a(q), $ = {
|
|
694
694
|
baseUnit: "V",
|
|
695
695
|
// transform: (val) => val * baseValue,
|
|
696
696
|
units: {
|
|
@@ -707,7 +707,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
707
707
|
convertValue: 1e3
|
|
708
708
|
}
|
|
709
709
|
}
|
|
710
|
-
},
|
|
710
|
+
}, ae = a($), w = {
|
|
711
711
|
baseUnit: "m3",
|
|
712
712
|
units: {
|
|
713
713
|
m3: {
|
|
@@ -743,7 +743,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
743
743
|
convertValue: 16387e-9
|
|
744
744
|
}
|
|
745
745
|
}
|
|
746
|
-
}, ne =
|
|
746
|
+
}, ne = a(w), _ = {
|
|
747
747
|
baseUnit: "m3/h",
|
|
748
748
|
units: {
|
|
749
749
|
"m3/h": {
|
|
@@ -783,7 +783,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
783
783
|
convertValue: 378541e-8 * 3600
|
|
784
784
|
}
|
|
785
785
|
}
|
|
786
|
-
},
|
|
786
|
+
}, re = a(_), D = {
|
|
787
787
|
baseUnit: "C",
|
|
788
788
|
units: {
|
|
789
789
|
C: {
|
|
@@ -804,7 +804,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
804
804
|
// Subtract 273.15 to convert from K to C
|
|
805
805
|
}
|
|
806
806
|
}
|
|
807
|
-
}, te =
|
|
807
|
+
}, te = a(D), I = {
|
|
808
808
|
baseUnit: "Pa/m",
|
|
809
809
|
units: {
|
|
810
810
|
"Pa/m": {
|
|
@@ -897,29 +897,83 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
897
897
|
// Remove atmospheric pressure divided by 1000
|
|
898
898
|
}
|
|
899
899
|
}
|
|
900
|
-
},
|
|
900
|
+
}, oe = a(I), A = {
|
|
901
|
+
baseUnit: "kg/Sm3",
|
|
902
|
+
units: {
|
|
903
|
+
"kg/Sm3": {
|
|
904
|
+
name: "Kilogram per Standard Cubic Meter",
|
|
905
|
+
convertValue: 1
|
|
906
|
+
},
|
|
907
|
+
"g/Sm3": {
|
|
908
|
+
name: "Gram per Standard Cubic Meter",
|
|
909
|
+
convertValue: 1e-3
|
|
910
|
+
// 1 g = 0.001 kg
|
|
911
|
+
},
|
|
912
|
+
"mg/Sm3": {
|
|
913
|
+
name: "Milligram per Standard Cubic Meter",
|
|
914
|
+
convertValue: 1e-6
|
|
915
|
+
// 1 mg = 1e-6 kg
|
|
916
|
+
},
|
|
917
|
+
"kg/MSm3": {
|
|
918
|
+
name: "Kilogram per Thousand Standard Cubic Meters",
|
|
919
|
+
convertValue: 1 / 1e3
|
|
920
|
+
// M = thousand Sm3
|
|
921
|
+
},
|
|
922
|
+
"kg/MMSm3": {
|
|
923
|
+
name: "Kilogram per Million Standard Cubic Meters",
|
|
924
|
+
convertValue: 1 / 1e6
|
|
925
|
+
// MM = million Sm3
|
|
926
|
+
},
|
|
927
|
+
"g/SCF": {
|
|
928
|
+
name: "Gram per Standard Cubic Foot",
|
|
929
|
+
convertValue: 1e-3 * 35.3147
|
|
930
|
+
// 1 g = 0.001 kg, 1 Sm3 = 35.3147 SCF
|
|
931
|
+
},
|
|
932
|
+
"lb/SCF": {
|
|
933
|
+
name: "Pound per Standard Cubic Foot",
|
|
934
|
+
convertValue: 0.453592 * 35.3147
|
|
935
|
+
// 1 lb = 0.453592 kg, 1 Sm3 = 35.3147 SCF
|
|
936
|
+
},
|
|
937
|
+
"lb/MSCF": {
|
|
938
|
+
name: "Pound per Thousand Standard Cubic Feet",
|
|
939
|
+
convertValue: 0.453592 * 35.3147 / 1e3
|
|
940
|
+
// M = thousand SCF
|
|
941
|
+
},
|
|
942
|
+
"lb/MMSCF": {
|
|
943
|
+
name: "Pound per Million Standard Cubic Feet",
|
|
944
|
+
convertValue: 0.453592 * 35.3147 / 1e6
|
|
945
|
+
// MM = million SCF
|
|
946
|
+
},
|
|
947
|
+
"kg/MMSCF": {
|
|
948
|
+
name: "Kilogram per Million Standard Cubic Feet",
|
|
949
|
+
convertValue: 35.3147 / 1e6
|
|
950
|
+
// Conversion factor from kg/Sm3 to kg/MMSCF
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
}, ce = a(A);
|
|
901
954
|
export {
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
Q as
|
|
955
|
+
B as acceleration,
|
|
956
|
+
N as area,
|
|
957
|
+
T as density,
|
|
958
|
+
W as electricCharge,
|
|
959
|
+
H as electricCurrent,
|
|
960
|
+
J as energy,
|
|
961
|
+
L as force,
|
|
962
|
+
O as length,
|
|
963
|
+
z as mass,
|
|
964
|
+
j as massFlow,
|
|
965
|
+
ce as massPerStandardVolume,
|
|
966
|
+
E as power,
|
|
967
|
+
x as pressure,
|
|
968
|
+
Y as pressureManometric,
|
|
969
|
+
oe as pressurePerLength,
|
|
970
|
+
Q as speed,
|
|
971
|
+
R as standardVolumetricFlow,
|
|
918
972
|
te as temperature,
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
973
|
+
Z as time,
|
|
974
|
+
X as torque,
|
|
975
|
+
ee as viscosity,
|
|
976
|
+
ae as voltage,
|
|
923
977
|
ne as volume,
|
|
924
|
-
|
|
978
|
+
re as volumetricFlow
|
|
925
979
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e["engineering-unit-converter"]={}))})(this,function(e){"use strict";var R=Object.defineProperty;var X=(e,t,o)=>t in e?R(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var u=(e,t,o)=>(X(e,typeof t!="symbol"?t+"":t,o),o);class t{constructor(a,r){u(this,"_definitions");u(this,"_val");u(this,"_fromUnit",null);this._definitions=r,this._val=a}from(a){return this._checkUnit(a),this._fromUnit=a,this}to(a){if(!this._fromUnit)throw new Error('Please specify the "from" unit using the from() method before calling to().');this._checkUnit(a);const r=this._getUnit(this._fromUnit),c=this._getUnit(a);let l=this._val;return r.offset!==0&&(l-=r.offset),l=l*r.convertValue/c.convertValue,c.offset!==0&&(l+=c.offset),l}_getUnit(a){const r=this._definitions.units[a],c=r.offset??0;return{convertValue:r.convertValue,offset:c}}_checkUnit(a){const r=Object.keys(this._definitions.units);if(!r.includes(a))throw new Error(`Invalid unit "${a}". Available units: ${r.join(", ")}`)}}class o{constructor(a,r){u(this,"_internalConverter");this._internalConverter=new t(a,r)}from(a){return this._internalConverter.from(a),new i(this._internalConverter)}}class i{constructor(a){this._internalConverter=a}to(a){return this._internalConverter.to(a)}}const n=m=>a=>new o(a,m),s={baseUnit:"m/s2",units:{"m/s2":{name:"Meter per Second Squared",convertValue:1},"km/s2":{name:"Kilometer per Second Squared",convertValue:1e3},"cm/s2":{name:"Centimeter per Second Squared",convertValue:1/100},"ft/s2":{name:"Foot per Second Squared",convertValue:1/3.28084}}},v=n(s),V={baseUnit:"m2",units:{m2:{name:"Square Meter",convertValue:1},km2:{name:"Square Kilometer",convertValue:1/1e-6},cm2:{name:"Square Centimeter",convertValue:1/1e4},mm2:{name:"Square Millimeter",convertValue:1/1e6},sqin:{name:"Square Inch",convertValue:1/1550.0031},sqft:{name:"Square Foot",convertValue:1/10.763888889},sqyd:{name:"Square Yard",convertValue:1/1.1959876543333339},acre:{name:"Acre",convertValue:1/247105e-9},hectare:{name:"Hectare",convertValue:1/1e-4}}},p=n(V),f={baseUnit:"kg/m3",units:{"kg/m3":{name:"Kilogram per cubic meter",convertValue:1},"lb/ft3":{name:"Pound per cubic foot",convertValue:1/.062427962},"g/cm3":{name:"Gram per cubic centimeter",convertValue:.001},"kg/ft3":{name:"Kilogram per cubic foot",convertValue:1/.0283168},"lb/m3":{name:"Pound per cubic meter",convertValue:1/2.20462}}},d=n(f),h=n({baseUnit:"C",units:{C:{name:"Coulomb",convertValue:1},mC:{name:"MilliCoulomb",convertValue:.001},μC:{name:"MicroCoulomb",convertValue:1e-6},nC:{name:"NanoCoulomb",convertValue:1e-9},pC:{name:"PicoCoulomb",convertValue:1e-12}}}),g=n({baseUnit:"A",units:{A:{name:"Ampere",convertValue:1},mA:{name:"Milliampere",convertValue:.001},μA:{name:"Microampere",convertValue:1e-6},nA:{name:"Nanoampere",convertValue:1e-9},pA:{name:"Picoampere",convertValue:1e-12}}}),b={baseUnit:"J",units:{J:{name:"Joule",convertValue:1},kJ:{name:"Kilojoule",convertValue:1/.001},cal:{name:"Calorie",convertValue:1/.239006},kcal:{name:"Kilocalorie",convertValue:1/239006e-9},Wh:{name:"Watt-hour",convertValue:1/277778e-9},kWh:{name:"Kilowatt-hour",convertValue:1/277778e-12},BTU:{name:"British Thermal Unit",convertValue:1/947817e-9}}},C=n(b),M={baseUnit:"N",units:{N:{name:"Newton",convertValue:1},dyn:{name:"Dyne",convertValue:1e-5},lbf:{name:"Pound-force",convertValue:1/.224809},kgf:{name:"Kilogram-force",convertValue:9.80665}}},P=n(M),S=n({baseUnit:"m",units:{m:{name:"Meter",convertValue:1},km:{name:"Kilometer",convertValue:1e3},mm:{name:"Millimeter",convertValue:.001},cm:{name:"Centimeter",convertValue:.01},in:{name:"Inch",convertValue:.0254},ft:{name:"Foot",convertValue:.3048},um:{name:"Micrometer",convertValue:1e-6},nm:{name:"Nanometer",convertValue:1e-9}}}),k={baseUnit:"kg/s",units:{"kg/s":{name:"Kilogram per second",convertValue:1},"kg/h":{name:"Kilogram per hour",convertValue:1/3600},"lb/day":{name:"Pound per day",convertValue:1/190479},"g/s":{name:"Gram per second",convertValue:.001},"lb/h":{name:"Pound per hour",convertValue:1/(190479/24)},"ton/day":{name:"Ton per day",convertValue:1/(34762.5/365)},"oz/min":{name:"Ounce per minute",convertValue:1/2116.4394433764},"ton/year":{name:"Ton per year",convertValue:1/34762.5},"lb/s":{name:"Pound per second",convertValue:1/(190479/86400)},"kg/day":{name:"Kilogram per day",convertValue:1/86400}}},y=n(k),K=n({baseUnit:"kg",units:{kg:{name:"Kilogram",convertValue:1},g:{name:"Gram",convertValue:.001},lb:{name:"Pound",convertValue:.453592},oz:{name:"Ounce",convertValue:.0283495},ton:{name:"Ton",convertValue:1e3},mg:{name:"Miligram",convertValue:1e-6}}}),U={baseUnit:"W",units:{W:{name:"Watt",convertValue:1},kW:{name:"Kilowatt",convertValue:1e3},hp:{name:"Horsepower",convertValue:745.7},"BTU/h":{name:"British Thermal Unit per hour",convertValue:1/3.41214},"cal/s":{name:"Calorie per second",convertValue:1/.23884589662749595}}},q=n(U),F=n({baseUnit:"Pag",units:{Pag:{name:"Pascal",convertValue:1},kPag:{name:"Kilopascal",convertValue:1e3},MPag:{name:"Megapascal",convertValue:1e6},barg:{name:"Bar",convertValue:1e5},atmg:{name:"Atmosphere",convertValue:101325},psig:{name:"Pound per Square Inch",convertValue:6894.76},"kg/cm2g":{name:"Kilogram per Square Centimeter",convertValue:98066.5}}}),w={baseUnit:"Pa",units:{Pa:{name:"Pascal",convertValue:1},kPa:{name:"Kilopascal",convertValue:1e3},MPa:{name:"Megapascal",convertValue:1e6},bar:{name:"Bar",convertValue:1e5},atm:{name:"Atmosphere",convertValue:101325},psi:{name:"Pound per Square Inch",convertValue:6894.76},"kg/cm2":{name:"Kilogram per Square Centimeter",convertValue:98066.5},Pag:{name:"Pascal",convertValue:1,offset:-1},kPag:{name:"Kilopascal",convertValue:1e3,offset:-1},MPag:{name:"Megapascal",convertValue:1e6,offset:-1},barg:{name:"Bar",convertValue:1e5,offset:-1},atmg:{name:"Atmosphere",convertValue:101325,offset:-1},psig:{name:"Pound per Square Inch",convertValue:6894.76,offset:-1},"kg/cm2g":{name:"Kilogram per Square Centimeter",convertValue:98066.5,offset:-1},ksi:{name:"1000 Pound per Square Inch",convertValue:6894.76*1e3}}},$=n(w),_={baseUnit:"m/s",units:{"m/s":{name:"Meter per second",convertValue:1},"km/h":{name:"Kilometer per hour",convertValue:.277778},"ft/s":{name:"Foot per second",convertValue:.3048},"mi/h":{name:"Mile per hour",convertValue:.44704},knot:{name:"Knot",convertValue:.514444},"m/h":{name:"Meter per hour",convertValue:1/3600},"ft/h":{name:"Foot per hour",convertValue:1/11811},mph:{name:"Miles per hour",convertValue:2.23694}}},D=n(_),I={baseUnit:"SCMD",units:{SCMD:{name:"Standard Cubic Meters per Day",convertValue:1},SCFD:{name:"Standard Cubic Feet per Day",convertValue:1/35.3147},MSCMD:{name:"Million Standard Cubic Meters per Day",convertValue:1e3},MMSCMD:{name:"Million Million Standard Cubic Meters per Day",convertValue:1e6},MSCFD:{name:"Million Standard Cubic Feet per Day",convertValue:1/35.3147*1e3},MMSCFD:{name:"Million Million Standard Cubic Feet per Day",convertValue:1/35.3147*1e6},"Sm3/h":{name:"Standard Cubic Meter per Hour",convertValue:24},"Sft3/h":{name:"Standard Cubic Feet per Hour",convertValue:1/35.3147*24}}},A=n(I),G=n({baseUnit:"N/m",units:{"N/m":{name:"Newton per Meter",convertValue:1},"dyn/cm":{name:"Dyne per Centimeter",convertValue:.001},"lbf/ft":{name:"Pound-force per Foot",convertValue:14.5939},"mN/m":{name:"Millinewton per Meter",convertValue:.001},"lbf/in":{name:"Pound-force per Inch",convertValue:175.126836},"ozf/in":{name:"Ounce-force per Inch",convertValue:10.945427}}}),B={baseUnit:"sec",units:{sec:{name:"Second",convertValue:1},min:{name:"Minute",convertValue:60},hr:{name:"Hour",convertValue:3600},day:{name:"Day",convertValue:86400},month:{name:"Month",convertValue:86400*30},year:{name:"Year",convertValue:86400*365}}},N=n(B),T={baseUnit:"cP",units:{cP:{name:"Centipoise",convertValue:1},Pas:{name:"Pascal second",convertValue:1/.001},"lb/fts":{name:"Pound per second-foot",convertValue:1/.000671968994813},"kg/ms":{name:"Kilogram per meter-second-hour",convertValue:1/.001},"lb/fth":{name:"Pound per hour-foot",convertValue:1/2.4190883105},"kg/mh":{name:"Kilogram per meter-second-meter",convertValue:1/3.6}}},W=n(T),j=n({baseUnit:"V",units:{V:{name:"Volt",convertValue:1},mV:{name:"Millivolt",convertValue:.001},kV:{name:"Kilovolt",convertValue:1e3}}}),H={baseUnit:"m3",units:{m3:{name:"Cubic Meter",convertValue:1},liter:{name:"Liter",convertValue:.001},cm3:{name:"Cubic Centimeter",convertValue:1e-6},mm3:{name:"Cubic Millimeter",convertValue:1e-9},gallon:{name:"Gallon",convertValue:.00454609},quart:{name:"Quart",convertValue:1/879.877},ft3:{name:"Cubic Feet",convertValue:.0283168},in3:{name:"Cubic inch",convertValue:16387e-9}}},O=n(H),J={baseUnit:"m3/h",units:{"m3/h":{name:"Cubic meter per hour",convertValue:1},"m3/day":{name:"Cubic meter per day",convertValue:1/24},"ft3/h":{name:"Cubic foot per hour",convertValue:.0283168},"ft3/day":{name:"Cubic foot per day",convertValue:.0283168/24},"gal/h":{name:"Gallon per hour",convertValue:.00378541},"gal/day":{name:"Gallon per day",convertValue:.00378541/24},"m3/s":{name:"Cubic meter per second",convertValue:3600},"ft3/s":{name:"Cubic foot per second",convertValue:1/.00980963},"gal/s":{name:"Gallon per second",convertValue:.00378541*3600}}},L=n(J),z={baseUnit:"C",units:{C:{name:"Celsius",convertValue:1,offset:0},F:{name:"Fahrenheit",convertValue:5/9,offset:32},K:{name:"Kelvin",convertValue:1,offset:273.15}}},E=n(z),Y={baseUnit:"Pa/m",units:{"Pa/m":{name:"Pascal per Meter",convertValue:1},"Pa/km":{name:"Pascal per Kilometer",convertValue:1/1e3},"kPa/m":{name:"Kilopascal per Meter",convertValue:1e3},"kPa/km":{name:"Kilopascal per Meter",convertValue:1},"bar/m":{name:"Bar per Meter",convertValue:1e5},"bar/km":{name:"Bar per Kilometer",convertValue:100},"psi/ft":{name:"Pound per Square Inch per Foot",convertValue:6894.76/3.28084},"psi/m":{name:"Pound per Square Inch per Meter",convertValue:6894.76},"atm/m":{name:"Atmosphere per Meter",convertValue:101325},"atm/km":{name:"Atmosphere per Kilometer",convertValue:101.325},"kg/cm2/m":{name:"Kilogram per Square Centimeter per Meter",convertValue:98066.5},"kg/cm2/km":{name:"Kilogram per Square Centimeter per Kilometer",convertValue:98.0665},"barg/m":{name:"Bar Gauge per Meter",convertValue:1e5,offset:-101325},"psig/ft":{name:"Pound per Square Inch Gauge per Foot",convertValue:6894.76/3.28084,offset:-101325},"psig/m":{name:"Pound per Square Inch Gauge per Meter",convertValue:6894.76,offset:-101325},"kg/cm2g/m":{name:"Kilogram per Square Centimeter Gauge per Meter",convertValue:98066.5,offset:-101325},"kg/cm2g/km":{name:"Kilogram per Square Centimeter Gauge per Kilometer",convertValue:98.0665,offset:-101.325}}},Q=n(Y);e.acceleration=v,e.area=p,e.density=d,e.electricCharge=h,e.electricCurrent=g,e.energy=C,e.force=P,e.length=S,e.mass=K,e.massFlow=y,e.power=q,e.pressure=$,e.pressureManometric=F,e.pressurePerLength=Q,e.speed=D,e.standardVolumetricFlow=A,e.temperature=E,e.time=N,e.torque=G,e.viscosity=W,e.voltage=j,e.volume=O,e.volumetricFlow=L,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports):typeof define=="function"&&define.amd?define(["exports"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e["engineering-unit-converter"]={}))})(this,function(e){"use strict";var Z=Object.defineProperty;var x=(e,t,o)=>t in e?Z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var u=(e,t,o)=>(x(e,typeof t!="symbol"?t+"":t,o),o);class t{constructor(a,r){u(this,"_definitions");u(this,"_val");u(this,"_fromUnit",null);this._definitions=r,this._val=a}from(a){return this._checkUnit(a),this._fromUnit=a,this}to(a){if(!this._fromUnit)throw new Error('Please specify the "from" unit using the from() method before calling to().');this._checkUnit(a);const r=this._getUnit(this._fromUnit),c=this._getUnit(a);let l=this._val;return r.offset!==0&&(l-=r.offset),l=l*r.convertValue/c.convertValue,c.offset!==0&&(l+=c.offset),l}_getUnit(a){const r=this._definitions.units[a],c=r.offset??0;return{convertValue:r.convertValue,offset:c}}_checkUnit(a){const r=Object.keys(this._definitions.units);if(!r.includes(a))throw new Error(`Invalid unit "${a}". Available units: ${r.join(", ")}`)}}class o{constructor(a,r){u(this,"_internalConverter");this._internalConverter=new t(a,r)}from(a){return this._internalConverter.from(a),new i(this._internalConverter)}}class i{constructor(a){this._internalConverter=a}to(a){return this._internalConverter.to(a)}}const n=m=>a=>new o(a,m),s={baseUnit:"m/s2",units:{"m/s2":{name:"Meter per Second Squared",convertValue:1},"km/s2":{name:"Kilometer per Second Squared",convertValue:1e3},"cm/s2":{name:"Centimeter per Second Squared",convertValue:1/100},"ft/s2":{name:"Foot per Second Squared",convertValue:1/3.28084}}},v=n(s),V={baseUnit:"m2",units:{m2:{name:"Square Meter",convertValue:1},km2:{name:"Square Kilometer",convertValue:1/1e-6},cm2:{name:"Square Centimeter",convertValue:1/1e4},mm2:{name:"Square Millimeter",convertValue:1/1e6},sqin:{name:"Square Inch",convertValue:1/1550.0031},sqft:{name:"Square Foot",convertValue:1/10.763888889},sqyd:{name:"Square Yard",convertValue:1/1.1959876543333339},acre:{name:"Acre",convertValue:1/247105e-9},hectare:{name:"Hectare",convertValue:1/1e-4}}},d=n(V),p={baseUnit:"kg/m3",units:{"kg/m3":{name:"Kilogram per cubic meter",convertValue:1},"lb/ft3":{name:"Pound per cubic foot",convertValue:1/.062427962},"g/cm3":{name:"Gram per cubic centimeter",convertValue:.001},"kg/ft3":{name:"Kilogram per cubic foot",convertValue:1/.0283168},"lb/m3":{name:"Pound per cubic meter",convertValue:1/2.20462}}},g=n(p),f=n({baseUnit:"C",units:{C:{name:"Coulomb",convertValue:1},mC:{name:"MilliCoulomb",convertValue:.001},μC:{name:"MicroCoulomb",convertValue:1e-6},nC:{name:"NanoCoulomb",convertValue:1e-9},pC:{name:"PicoCoulomb",convertValue:1e-12}}}),h=n({baseUnit:"A",units:{A:{name:"Ampere",convertValue:1},mA:{name:"Milliampere",convertValue:.001},μA:{name:"Microampere",convertValue:1e-6},nA:{name:"Nanoampere",convertValue:1e-9},pA:{name:"Picoampere",convertValue:1e-12}}}),b={baseUnit:"J",units:{J:{name:"Joule",convertValue:1},kJ:{name:"Kilojoule",convertValue:1/.001},cal:{name:"Calorie",convertValue:1/.239006},kcal:{name:"Kilocalorie",convertValue:1/239006e-9},Wh:{name:"Watt-hour",convertValue:1/277778e-9},kWh:{name:"Kilowatt-hour",convertValue:1/277778e-12},BTU:{name:"British Thermal Unit",convertValue:1/947817e-9}}},C=n(b),M={baseUnit:"N",units:{N:{name:"Newton",convertValue:1},dyn:{name:"Dyne",convertValue:1e-5},lbf:{name:"Pound-force",convertValue:1/.224809},kgf:{name:"Kilogram-force",convertValue:9.80665}}},S=n(M),P=n({baseUnit:"m",units:{m:{name:"Meter",convertValue:1},km:{name:"Kilometer",convertValue:1e3},mm:{name:"Millimeter",convertValue:.001},cm:{name:"Centimeter",convertValue:.01},in:{name:"Inch",convertValue:.0254},ft:{name:"Foot",convertValue:.3048},um:{name:"Micrometer",convertValue:1e-6},nm:{name:"Nanometer",convertValue:1e-9}}}),k={baseUnit:"kg/s",units:{"kg/s":{name:"Kilogram per second",convertValue:1},"kg/h":{name:"Kilogram per hour",convertValue:1/3600},"lb/day":{name:"Pound per day",convertValue:1/190479},"g/s":{name:"Gram per second",convertValue:.001},"lb/h":{name:"Pound per hour",convertValue:1/(190479/24)},"ton/day":{name:"Ton per day",convertValue:1/(34762.5/365)},"oz/min":{name:"Ounce per minute",convertValue:1/2116.4394433764},"ton/year":{name:"Ton per year",convertValue:1/34762.5},"lb/s":{name:"Pound per second",convertValue:1/(190479/86400)},"kg/day":{name:"Kilogram per day",convertValue:1/86400}}},y=n(k),K=n({baseUnit:"kg",units:{kg:{name:"Kilogram",convertValue:1},g:{name:"Gram",convertValue:.001},lb:{name:"Pound",convertValue:.453592},oz:{name:"Ounce",convertValue:.0283495},ton:{name:"Ton",convertValue:1e3},mg:{name:"Miligram",convertValue:1e-6}}}),F={baseUnit:"W",units:{W:{name:"Watt",convertValue:1},kW:{name:"Kilowatt",convertValue:1e3},hp:{name:"Horsepower",convertValue:745.7},"BTU/h":{name:"British Thermal Unit per hour",convertValue:1/3.41214},"cal/s":{name:"Calorie per second",convertValue:1/.23884589662749595}}},U=n(F),q=n({baseUnit:"Pag",units:{Pag:{name:"Pascal",convertValue:1},kPag:{name:"Kilopascal",convertValue:1e3},MPag:{name:"Megapascal",convertValue:1e6},barg:{name:"Bar",convertValue:1e5},atmg:{name:"Atmosphere",convertValue:101325},psig:{name:"Pound per Square Inch",convertValue:6894.76},"kg/cm2g":{name:"Kilogram per Square Centimeter",convertValue:98066.5}}}),$={baseUnit:"Pa",units:{Pa:{name:"Pascal",convertValue:1},kPa:{name:"Kilopascal",convertValue:1e3},MPa:{name:"Megapascal",convertValue:1e6},bar:{name:"Bar",convertValue:1e5},atm:{name:"Atmosphere",convertValue:101325},psi:{name:"Pound per Square Inch",convertValue:6894.76},"kg/cm2":{name:"Kilogram per Square Centimeter",convertValue:98066.5},Pag:{name:"Pascal",convertValue:1,offset:-1},kPag:{name:"Kilopascal",convertValue:1e3,offset:-1},MPag:{name:"Megapascal",convertValue:1e6,offset:-1},barg:{name:"Bar",convertValue:1e5,offset:-1},atmg:{name:"Atmosphere",convertValue:101325,offset:-1},psig:{name:"Pound per Square Inch",convertValue:6894.76,offset:-1},"kg/cm2g":{name:"Kilogram per Square Centimeter",convertValue:98066.5,offset:-1},ksi:{name:"1000 Pound per Square Inch",convertValue:6894.76*1e3}}},w=n($),_={baseUnit:"m/s",units:{"m/s":{name:"Meter per second",convertValue:1},"km/h":{name:"Kilometer per hour",convertValue:.277778},"ft/s":{name:"Foot per second",convertValue:.3048},"mi/h":{name:"Mile per hour",convertValue:.44704},knot:{name:"Knot",convertValue:.514444},"m/h":{name:"Meter per hour",convertValue:1/3600},"ft/h":{name:"Foot per hour",convertValue:1/11811},mph:{name:"Miles per hour",convertValue:2.23694}}},D=n(_),I={baseUnit:"SCMD",units:{SCMD:{name:"Standard Cubic Meters per Day",convertValue:1},SCFD:{name:"Standard Cubic Feet per Day",convertValue:1/35.3147},MSCMD:{name:"Million Standard Cubic Meters per Day",convertValue:1e3},MMSCMD:{name:"Million Million Standard Cubic Meters per Day",convertValue:1e6},MSCFD:{name:"Million Standard Cubic Feet per Day",convertValue:1/35.3147*1e3},MMSCFD:{name:"Million Million Standard Cubic Feet per Day",convertValue:1/35.3147*1e6},"Sm3/h":{name:"Standard Cubic Meter per Hour",convertValue:24},"Sft3/h":{name:"Standard Cubic Feet per Hour",convertValue:1/35.3147*24}}},A=n(I),G=n({baseUnit:"N/m",units:{"N/m":{name:"Newton per Meter",convertValue:1},"dyn/cm":{name:"Dyne per Centimeter",convertValue:.001},"lbf/ft":{name:"Pound-force per Foot",convertValue:14.5939},"mN/m":{name:"Millinewton per Meter",convertValue:.001},"lbf/in":{name:"Pound-force per Inch",convertValue:175.126836},"ozf/in":{name:"Ounce-force per Inch",convertValue:10.945427}}}),T={baseUnit:"sec",units:{sec:{name:"Second",convertValue:1},min:{name:"Minute",convertValue:60},hr:{name:"Hour",convertValue:3600},day:{name:"Day",convertValue:86400},month:{name:"Month",convertValue:86400*30},year:{name:"Year",convertValue:86400*365}}},B=n(T),N={baseUnit:"cP",units:{cP:{name:"Centipoise",convertValue:1},Pas:{name:"Pascal second",convertValue:1/.001},"lb/fts":{name:"Pound per second-foot",convertValue:1/.000671968994813},"kg/ms":{name:"Kilogram per meter-second-hour",convertValue:1/.001},"lb/fth":{name:"Pound per hour-foot",convertValue:1/2.4190883105},"kg/mh":{name:"Kilogram per meter-second-meter",convertValue:1/3.6}}},W=n(N),j=n({baseUnit:"V",units:{V:{name:"Volt",convertValue:1},mV:{name:"Millivolt",convertValue:.001},kV:{name:"Kilovolt",convertValue:1e3}}}),H={baseUnit:"m3",units:{m3:{name:"Cubic Meter",convertValue:1},liter:{name:"Liter",convertValue:.001},cm3:{name:"Cubic Centimeter",convertValue:1e-6},mm3:{name:"Cubic Millimeter",convertValue:1e-9},gallon:{name:"Gallon",convertValue:.00454609},quart:{name:"Quart",convertValue:1/879.877},ft3:{name:"Cubic Feet",convertValue:.0283168},in3:{name:"Cubic inch",convertValue:16387e-9}}},O=n(H),J={baseUnit:"m3/h",units:{"m3/h":{name:"Cubic meter per hour",convertValue:1},"m3/day":{name:"Cubic meter per day",convertValue:1/24},"ft3/h":{name:"Cubic foot per hour",convertValue:.0283168},"ft3/day":{name:"Cubic foot per day",convertValue:.0283168/24},"gal/h":{name:"Gallon per hour",convertValue:.00378541},"gal/day":{name:"Gallon per day",convertValue:.00378541/24},"m3/s":{name:"Cubic meter per second",convertValue:3600},"ft3/s":{name:"Cubic foot per second",convertValue:1/.00980963},"gal/s":{name:"Gallon per second",convertValue:.00378541*3600}}},L=n(J),z={baseUnit:"C",units:{C:{name:"Celsius",convertValue:1,offset:0},F:{name:"Fahrenheit",convertValue:5/9,offset:32},K:{name:"Kelvin",convertValue:1,offset:273.15}}},E=n(z),Y={baseUnit:"Pa/m",units:{"Pa/m":{name:"Pascal per Meter",convertValue:1},"Pa/km":{name:"Pascal per Kilometer",convertValue:1/1e3},"kPa/m":{name:"Kilopascal per Meter",convertValue:1e3},"kPa/km":{name:"Kilopascal per Meter",convertValue:1},"bar/m":{name:"Bar per Meter",convertValue:1e5},"bar/km":{name:"Bar per Kilometer",convertValue:100},"psi/ft":{name:"Pound per Square Inch per Foot",convertValue:6894.76/3.28084},"psi/m":{name:"Pound per Square Inch per Meter",convertValue:6894.76},"atm/m":{name:"Atmosphere per Meter",convertValue:101325},"atm/km":{name:"Atmosphere per Kilometer",convertValue:101.325},"kg/cm2/m":{name:"Kilogram per Square Centimeter per Meter",convertValue:98066.5},"kg/cm2/km":{name:"Kilogram per Square Centimeter per Kilometer",convertValue:98.0665},"barg/m":{name:"Bar Gauge per Meter",convertValue:1e5,offset:-101325},"psig/ft":{name:"Pound per Square Inch Gauge per Foot",convertValue:6894.76/3.28084,offset:-101325},"psig/m":{name:"Pound per Square Inch Gauge per Meter",convertValue:6894.76,offset:-101325},"kg/cm2g/m":{name:"Kilogram per Square Centimeter Gauge per Meter",convertValue:98066.5,offset:-101325},"kg/cm2g/km":{name:"Kilogram per Square Centimeter Gauge per Kilometer",convertValue:98.0665,offset:-101.325}}},Q=n(Y),R={baseUnit:"kg/Sm3",units:{"kg/Sm3":{name:"Kilogram per Standard Cubic Meter",convertValue:1},"g/Sm3":{name:"Gram per Standard Cubic Meter",convertValue:.001},"mg/Sm3":{name:"Milligram per Standard Cubic Meter",convertValue:1e-6},"kg/MSm3":{name:"Kilogram per Thousand Standard Cubic Meters",convertValue:1/1e3},"kg/MMSm3":{name:"Kilogram per Million Standard Cubic Meters",convertValue:1/1e6},"g/SCF":{name:"Gram per Standard Cubic Foot",convertValue:.001*35.3147},"lb/SCF":{name:"Pound per Standard Cubic Foot",convertValue:.453592*35.3147},"lb/MSCF":{name:"Pound per Thousand Standard Cubic Feet",convertValue:.453592*35.3147/1e3},"lb/MMSCF":{name:"Pound per Million Standard Cubic Feet",convertValue:.453592*35.3147/1e6},"kg/MMSCF":{name:"Kilogram per Million Standard Cubic Feet",convertValue:35.3147/1e6}}},X=n(R);e.acceleration=v,e.area=d,e.density=g,e.electricCharge=f,e.electricCurrent=h,e.energy=C,e.force=S,e.length=P,e.mass=K,e.massFlow=y,e.massPerStandardVolume=X,e.power=U,e.pressure=w,e.pressureManometric=q,e.pressurePerLength=Q,e.speed=D,e.standardVolumetricFlow=A,e.temperature=E,e.time=B,e.torque=G,e.viscosity=W,e.voltage=j,e.volume=O,e.volumetricFlow=L,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.d.ts
CHANGED
|
@@ -21,3 +21,4 @@ export { default as volume } from './units/volume';
|
|
|
21
21
|
export { default as volumetricFlow } from './units/volumetric-flow';
|
|
22
22
|
export { default as temperature } from './units/temperature';
|
|
23
23
|
export { default as pressurePerLength } from './units/pressure-per-length';
|
|
24
|
+
export { default as massPerStandardVolume } from './units/mass-per-standard-volume';
|
package/dist/types.d.ts
CHANGED
|
@@ -296,6 +296,22 @@ export type StandardVolumetricFlow = {
|
|
|
296
296
|
baseUnit: 'SCMD';
|
|
297
297
|
units: StandardVolumetricFlowUnits;
|
|
298
298
|
};
|
|
299
|
+
export type MassPerStandardVolumeUnits = {
|
|
300
|
+
'kg/Sm3': UnitsValues;
|
|
301
|
+
'g/Sm3': UnitsValues;
|
|
302
|
+
'mg/Sm3': UnitsValues;
|
|
303
|
+
'kg/MSm3': UnitsValues;
|
|
304
|
+
'kg/MMSm3': UnitsValues;
|
|
305
|
+
'g/SCF': UnitsValues;
|
|
306
|
+
'lb/SCF': UnitsValues;
|
|
307
|
+
'lb/MSCF': UnitsValues;
|
|
308
|
+
'lb/MMSCF': UnitsValues;
|
|
309
|
+
'kg/MMSCF': UnitsValues;
|
|
310
|
+
};
|
|
311
|
+
export type MassPerStandardVolume = {
|
|
312
|
+
baseUnit: 'kg/Sm3';
|
|
313
|
+
units: MassPerStandardVolumeUnits;
|
|
314
|
+
};
|
|
299
315
|
export type TemperatureUnits = {
|
|
300
316
|
'C': UnitsValues;
|
|
301
317
|
'F': UnitsValues;
|
|
@@ -305,7 +321,7 @@ export type Temperature = {
|
|
|
305
321
|
baseUnit: 'C';
|
|
306
322
|
units: TemperatureUnits;
|
|
307
323
|
};
|
|
308
|
-
export type Measurement = Voltage | MassFlow | VolumetricFlow | Density | Viscosity | Length | Mass | Speed | Power | Energy | Area | Volume | Force | Torque | Time | ElectricCharge | ElectricCurrent | Acceleration | Pressure | PressureManometric | StandardVolumetricFlow | Temperature | PressurePerLength;
|
|
324
|
+
export type Measurement = Voltage | MassFlow | VolumetricFlow | Density | Viscosity | Length | Mass | Speed | Power | Energy | Area | Volume | Force | Torque | Time | ElectricCharge | ElectricCurrent | Acceleration | Pressure | PressureManometric | StandardVolumetricFlow | Temperature | PressurePerLength | MassPerStandardVolume;
|
|
309
325
|
export type MeasurementUnits<T extends Measurement> = T extends {
|
|
310
326
|
units: infer U;
|
|
311
327
|
} ? keyof U : never;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type MassPerStandardVolume } from '../types';
|
|
2
|
+
declare const _default: (val: number) => {
|
|
3
|
+
readonly _internalConverter: import("../internalConverter").default<MassPerStandardVolume>;
|
|
4
|
+
from<U extends keyof import("../types").MassPerStandardVolumeUnits>(fromUnit: U): {
|
|
5
|
+
readonly _internalConverter: import("../internalConverter").default<MassPerStandardVolume>;
|
|
6
|
+
to<U_1 extends keyof import("../types").MassPerStandardVolumeUnits>(toUnit: U_1): number;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"type": "git",
|
|
5
5
|
"url": "git+https://github.com/alanhaertel/engineering-unit-converter.git"
|
|
6
6
|
},
|
|
7
|
-
"version": "0.0.
|
|
7
|
+
"version": "0.0.15",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"units",
|
|
10
10
|
"engineering",
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"scripts": {
|
|
32
32
|
"dev": "vite",
|
|
33
33
|
"build": "tsc && vite build",
|
|
34
|
-
"preview": "vite preview"
|
|
34
|
+
"preview": "vite preview",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:watch": "vitest"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
39
|
"@changesets/cli": "^2.27.1",
|
|
@@ -41,12 +43,13 @@
|
|
|
41
43
|
"eslint-plugin-import": "^2.29.0",
|
|
42
44
|
"eslint-plugin-n": "^16.3.1",
|
|
43
45
|
"eslint-plugin-promise": "^6.1.1",
|
|
46
|
+
"tsx": "^4.19.1",
|
|
44
47
|
"typescript": "^5.3.2",
|
|
45
48
|
"vite": "^5.0.0",
|
|
46
49
|
"vite-plugin-dts": "^3.6.4",
|
|
47
|
-
"
|
|
50
|
+
"vitest": "^2.1.9"
|
|
48
51
|
},
|
|
49
52
|
"publishConfig": {
|
|
50
53
|
"access": "public"
|
|
51
54
|
}
|
|
52
|
-
}
|
|
55
|
+
}
|