engineering-unit-converter 0.0.8 → 0.0.10
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.
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
class
|
|
1
|
+
var l = Object.defineProperty;
|
|
2
|
+
var u = (t, e, a) => e in t ? l(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
|
|
3
|
+
var c = (t, e, a) => (u(t, typeof e != "symbol" ? e + "" : e, a), a);
|
|
4
|
+
class m {
|
|
5
5
|
constructor(e, a) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
c(this, "_definitions");
|
|
7
|
+
c(this, "_val");
|
|
8
|
+
c(this, "_fromUnit", null);
|
|
9
9
|
this._definitions = a, this._val = e;
|
|
10
10
|
}
|
|
11
11
|
from(e) {
|
|
@@ -15,11 +15,13 @@ 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 a = this._getUnit(
|
|
19
|
-
|
|
18
|
+
const a = this._getUnit(this._fromUnit), r = this._getUnit(e);
|
|
19
|
+
let o = this._val;
|
|
20
|
+
return a.offset !== 0 && (o -= a.offset), o = o * a.convertValue / r.convertValue, r.offset !== 0 && (o += r.offset), o;
|
|
20
21
|
}
|
|
21
22
|
_getUnit(e) {
|
|
22
|
-
|
|
23
|
+
const a = this._definitions.units[e], r = a.offset ?? 0;
|
|
24
|
+
return { convertValue: a.convertValue, offset: r };
|
|
23
25
|
}
|
|
24
26
|
_checkUnit(e) {
|
|
25
27
|
const a = Object.keys(this._definitions.units);
|
|
@@ -27,16 +29,16 @@ class u {
|
|
|
27
29
|
throw new Error(`Invalid unit "${e}". Available units: ${a.join(", ")}`);
|
|
28
30
|
}
|
|
29
31
|
}
|
|
30
|
-
class
|
|
32
|
+
class s {
|
|
31
33
|
constructor(e, a) {
|
|
32
|
-
|
|
33
|
-
this._internalConverter = new
|
|
34
|
+
c(this, "_internalConverter");
|
|
35
|
+
this._internalConverter = new m(e, a);
|
|
34
36
|
}
|
|
35
37
|
from(e) {
|
|
36
|
-
return this._internalConverter.from(e), new
|
|
38
|
+
return this._internalConverter.from(e), new i(this._internalConverter);
|
|
37
39
|
}
|
|
38
40
|
}
|
|
39
|
-
class
|
|
41
|
+
class i {
|
|
40
42
|
constructor(e) {
|
|
41
43
|
this._internalConverter = e;
|
|
42
44
|
}
|
|
@@ -44,7 +46,7 @@ class s {
|
|
|
44
46
|
return this._internalConverter.to(e);
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
|
-
const n = (t) => (e) => new
|
|
49
|
+
const n = (t) => (e) => new s(e, t), v = {
|
|
48
50
|
baseUnit: "m/s2",
|
|
49
51
|
units: {
|
|
50
52
|
"m/s2": {
|
|
@@ -64,7 +66,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
64
66
|
convertValue: 1 / 3.28084
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
|
-
},
|
|
69
|
+
}, I = n(v), V = {
|
|
68
70
|
baseUnit: "m2",
|
|
69
71
|
units: {
|
|
70
72
|
m2: {
|
|
@@ -112,7 +114,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
112
114
|
// Conversion factor from m2 to hectare
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
|
-
}, N = n(
|
|
117
|
+
}, N = n(V), p = {
|
|
116
118
|
baseUnit: "kg/m3",
|
|
117
119
|
units: {
|
|
118
120
|
"kg/m3": {
|
|
@@ -136,7 +138,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
136
138
|
convertValue: 1 / 2.20462
|
|
137
139
|
}
|
|
138
140
|
}
|
|
139
|
-
},
|
|
141
|
+
}, B = n(p), d = {
|
|
140
142
|
baseUnit: "C",
|
|
141
143
|
units: {
|
|
142
144
|
C: {
|
|
@@ -164,7 +166,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
164
166
|
// Conversion factor from C to pC
|
|
165
167
|
}
|
|
166
168
|
}
|
|
167
|
-
},
|
|
169
|
+
}, G = n(d), f = {
|
|
168
170
|
baseUnit: "A",
|
|
169
171
|
units: {
|
|
170
172
|
A: {
|
|
@@ -192,7 +194,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
192
194
|
// Conversion factor from A to pA
|
|
193
195
|
}
|
|
194
196
|
}
|
|
195
|
-
}, T = n(
|
|
197
|
+
}, T = n(f), h = {
|
|
196
198
|
baseUnit: "J",
|
|
197
199
|
units: {
|
|
198
200
|
J: {
|
|
@@ -230,7 +232,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
230
232
|
// Conversion factor from J to BTU
|
|
231
233
|
}
|
|
232
234
|
}
|
|
233
|
-
}, W = n(h),
|
|
235
|
+
}, W = n(h), g = {
|
|
234
236
|
baseUnit: "N",
|
|
235
237
|
units: {
|
|
236
238
|
N: {
|
|
@@ -253,7 +255,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
253
255
|
// Conversion factor from N to kgf
|
|
254
256
|
}
|
|
255
257
|
}
|
|
256
|
-
},
|
|
258
|
+
}, H = n(g), b = {
|
|
257
259
|
baseUnit: "m",
|
|
258
260
|
units: {
|
|
259
261
|
m: {
|
|
@@ -281,7 +283,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
281
283
|
// Conversion factor from m to ft
|
|
282
284
|
}
|
|
283
285
|
}
|
|
284
|
-
}, J = n(
|
|
286
|
+
}, J = n(b), C = {
|
|
285
287
|
baseUnit: "kg/s",
|
|
286
288
|
units: {
|
|
287
289
|
"kg/s": {
|
|
@@ -326,7 +328,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
326
328
|
// 1 day = 86400 seconds
|
|
327
329
|
}
|
|
328
330
|
}
|
|
329
|
-
},
|
|
331
|
+
}, O = n(C), M = {
|
|
330
332
|
baseUnit: "kg",
|
|
331
333
|
units: {
|
|
332
334
|
kg: {
|
|
@@ -354,7 +356,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
354
356
|
// Conversion factor from kg to ton
|
|
355
357
|
}
|
|
356
358
|
}
|
|
357
|
-
},
|
|
359
|
+
}, j = n(M), S = {
|
|
358
360
|
baseUnit: "W",
|
|
359
361
|
units: {
|
|
360
362
|
W: {
|
|
@@ -382,8 +384,8 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
382
384
|
// Conversion factor from W to cal/s
|
|
383
385
|
}
|
|
384
386
|
}
|
|
385
|
-
},
|
|
386
|
-
baseUnit: "
|
|
387
|
+
}, z = n(S), y = {
|
|
388
|
+
baseUnit: "Pag",
|
|
387
389
|
units: {
|
|
388
390
|
Pag: {
|
|
389
391
|
name: "Pascal",
|
|
@@ -420,7 +422,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
420
422
|
// Conversion factor from Pa to kg/cm²
|
|
421
423
|
}
|
|
422
424
|
}
|
|
423
|
-
},
|
|
425
|
+
}, E = n(y), P = {
|
|
424
426
|
baseUnit: "Pa",
|
|
425
427
|
units: {
|
|
426
428
|
Pa: {
|
|
@@ -456,9 +458,50 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
456
458
|
name: "Kilogram per Square Centimeter",
|
|
457
459
|
convertValue: 98066.5
|
|
458
460
|
// Conversion factor from Pa to kg/cm²
|
|
461
|
+
},
|
|
462
|
+
Pag: {
|
|
463
|
+
name: "Pascal",
|
|
464
|
+
convertValue: 1,
|
|
465
|
+
offset: -1
|
|
466
|
+
},
|
|
467
|
+
kPag: {
|
|
468
|
+
name: "Kilopascal",
|
|
469
|
+
convertValue: 1e3,
|
|
470
|
+
offset: -1
|
|
471
|
+
// Conversion factor from Pa to kPa
|
|
472
|
+
},
|
|
473
|
+
MPag: {
|
|
474
|
+
name: "Megapascal",
|
|
475
|
+
convertValue: 1e6,
|
|
476
|
+
offset: -1
|
|
477
|
+
// Conversion factor from Pa to MPa
|
|
478
|
+
},
|
|
479
|
+
barg: {
|
|
480
|
+
name: "Bar",
|
|
481
|
+
convertValue: 1e5,
|
|
482
|
+
offset: -1
|
|
483
|
+
// Conversion factor from Pa to Bar
|
|
484
|
+
},
|
|
485
|
+
atmg: {
|
|
486
|
+
name: "Atmosphere",
|
|
487
|
+
convertValue: 101325,
|
|
488
|
+
offset: -1
|
|
489
|
+
// Standard atmospheric pressure in Pa
|
|
490
|
+
},
|
|
491
|
+
psig: {
|
|
492
|
+
name: "Pound per Square Inch",
|
|
493
|
+
convertValue: 6894.76,
|
|
494
|
+
offset: -1
|
|
495
|
+
// Conversion factor from Pa to psi
|
|
496
|
+
},
|
|
497
|
+
"kg/cm2g": {
|
|
498
|
+
name: "Kilogram per Square Centimeter",
|
|
499
|
+
convertValue: 98066.5,
|
|
500
|
+
offset: -1
|
|
501
|
+
// Conversion factor from Pa to kg/cm²
|
|
459
502
|
}
|
|
460
503
|
}
|
|
461
|
-
},
|
|
504
|
+
}, x = n(P), U = {
|
|
462
505
|
baseUnit: "m/s",
|
|
463
506
|
units: {
|
|
464
507
|
"m/s": {
|
|
@@ -490,7 +533,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
490
533
|
convertValue: 1 / 11811
|
|
491
534
|
}
|
|
492
535
|
}
|
|
493
|
-
},
|
|
536
|
+
}, L = n(U), k = {
|
|
494
537
|
baseUnit: "SCMD",
|
|
495
538
|
units: {
|
|
496
539
|
SCMD: {
|
|
@@ -521,9 +564,19 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
521
564
|
name: "Million Million Standard Cubic Feet per Day",
|
|
522
565
|
convertValue: 1 / 35.3147 * 1e6
|
|
523
566
|
// Conversion factor from SCMD to MMSCFD
|
|
567
|
+
},
|
|
568
|
+
"Sm3/h": {
|
|
569
|
+
name: "Standard Cubic Meter per Hour",
|
|
570
|
+
convertValue: 24
|
|
571
|
+
// Conversion factor from SCMD to MMSCFD
|
|
572
|
+
},
|
|
573
|
+
"Sft3/h": {
|
|
574
|
+
name: "Standard Cubic Feet per Hour",
|
|
575
|
+
convertValue: 1 / 35.3147 * 24
|
|
576
|
+
// Conversion factor from SCMD to MMSCFD
|
|
524
577
|
}
|
|
525
578
|
}
|
|
526
|
-
},
|
|
579
|
+
}, Q = n(k), K = {
|
|
527
580
|
baseUnit: "N/m",
|
|
528
581
|
units: {
|
|
529
582
|
"N/m": {
|
|
@@ -536,14 +589,22 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
536
589
|
},
|
|
537
590
|
"lbf/ft": {
|
|
538
591
|
name: "Pound-force per Foot",
|
|
539
|
-
convertValue:
|
|
592
|
+
convertValue: 14.5939
|
|
540
593
|
},
|
|
541
594
|
"mN/m": {
|
|
542
595
|
name: "Millinewton per Meter",
|
|
543
596
|
convertValue: 1e-3
|
|
597
|
+
},
|
|
598
|
+
"lbf/in": {
|
|
599
|
+
name: "Pound-force per Inch",
|
|
600
|
+
convertValue: 175.126836
|
|
601
|
+
},
|
|
602
|
+
"ozf/in": {
|
|
603
|
+
name: "Ounce-force per Inch",
|
|
604
|
+
convertValue: 10.945427
|
|
544
605
|
}
|
|
545
606
|
}
|
|
546
|
-
},
|
|
607
|
+
}, Y = n(K), w = {
|
|
547
608
|
baseUnit: "s",
|
|
548
609
|
units: {
|
|
549
610
|
s: {
|
|
@@ -566,7 +627,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
566
627
|
// Conversion factor from seconds to days
|
|
567
628
|
}
|
|
568
629
|
}
|
|
569
|
-
},
|
|
630
|
+
}, R = n(w), q = {
|
|
570
631
|
baseUnit: "cP",
|
|
571
632
|
units: {
|
|
572
633
|
cP: {
|
|
@@ -594,7 +655,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
594
655
|
convertValue: 1 / 3.6
|
|
595
656
|
}
|
|
596
657
|
}
|
|
597
|
-
},
|
|
658
|
+
}, X = n(q), F = {
|
|
598
659
|
baseUnit: "V",
|
|
599
660
|
// transform: (val) => val * baseValue,
|
|
600
661
|
units: {
|
|
@@ -611,7 +672,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
611
672
|
convertValue: 1e3
|
|
612
673
|
}
|
|
613
674
|
}
|
|
614
|
-
},
|
|
675
|
+
}, Z = n(F), $ = {
|
|
615
676
|
baseUnit: "m3",
|
|
616
677
|
units: {
|
|
617
678
|
m3: {
|
|
@@ -639,7 +700,7 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
639
700
|
convertValue: 1 / 879.877
|
|
640
701
|
}
|
|
641
702
|
}
|
|
642
|
-
},
|
|
703
|
+
}, ee = n($), _ = {
|
|
643
704
|
baseUnit: "m3/h",
|
|
644
705
|
units: {
|
|
645
706
|
"m3/h": {
|
|
@@ -679,27 +740,49 @@ const n = (t) => (e) => new m(e, t), i = {
|
|
|
679
740
|
convertValue: 378541e-8 * 3600
|
|
680
741
|
}
|
|
681
742
|
}
|
|
682
|
-
},
|
|
743
|
+
}, ne = n(_), D = {
|
|
744
|
+
baseUnit: "C",
|
|
745
|
+
units: {
|
|
746
|
+
C: {
|
|
747
|
+
name: "Celsius",
|
|
748
|
+
convertValue: 1,
|
|
749
|
+
offset: 0
|
|
750
|
+
},
|
|
751
|
+
F: {
|
|
752
|
+
name: "Fahrenheit",
|
|
753
|
+
convertValue: 5 / 9,
|
|
754
|
+
// Inverse of 9/5
|
|
755
|
+
offset: 32
|
|
756
|
+
},
|
|
757
|
+
K: {
|
|
758
|
+
name: "Kelvin",
|
|
759
|
+
convertValue: 1,
|
|
760
|
+
offset: 273.15
|
|
761
|
+
// Subtract 273.15 to convert from K to C
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
}, ae = n(D);
|
|
683
765
|
export {
|
|
684
|
-
|
|
766
|
+
I as acceleration,
|
|
685
767
|
N as area,
|
|
686
|
-
|
|
687
|
-
|
|
768
|
+
B as density,
|
|
769
|
+
G as electricCharge,
|
|
688
770
|
T as electricCurrent,
|
|
689
771
|
W as energy,
|
|
690
|
-
|
|
772
|
+
H as force,
|
|
691
773
|
J as length,
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
X as
|
|
703
|
-
Z as
|
|
704
|
-
ee as
|
|
774
|
+
j as mass,
|
|
775
|
+
O as massFlow,
|
|
776
|
+
z as power,
|
|
777
|
+
x as pressure,
|
|
778
|
+
E as pressureManometric,
|
|
779
|
+
L as speed,
|
|
780
|
+
Q as standardVolumetricFlow,
|
|
781
|
+
ae as temperature,
|
|
782
|
+
R as time,
|
|
783
|
+
Y as torque,
|
|
784
|
+
X as viscosity,
|
|
785
|
+
Z as voltage,
|
|
786
|
+
ee as volume,
|
|
787
|
+
ne as volumetricFlow
|
|
705
788
|
};
|
|
@@ -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
|
|
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 E=Object.defineProperty;var L=(e,t,o)=>t in e?E(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var u=(e,t,o)=>(L(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),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}}},h=n(f),p=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}}},y=n(M),S=n({baseUnit:"m",units:{m:{name:"Meter",convertValue:1},mm:{name:"Millimeter",convertValue:.001},cm:{name:"Centimeter",convertValue:.01},in:{name:"Inch",convertValue:.0254},ft:{name:"Foot",convertValue:.3048}}}),P={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}}},U=n(P),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}}}),K={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(K),w=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}}}),F=n({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}}}),$={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}}},_=n($),D={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(D),I=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=n({baseUnit:"s",units:{s:{name:"Second",convertValue:1},min:{name:"Minute",convertValue:60},hr:{name:"Hour",convertValue:3600},day:{name:"Day",convertValue:86400}}}),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}}},B=n(N),G=n({baseUnit:"V",units:{V:{name:"Volt",convertValue:1},mV:{name:"Millivolt",convertValue:.001},kV:{name:"Kilovolt",convertValue:1e3}}}),W={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}}},j=n(W),H={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}}},O=n(H),J={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}}},z=n(J);e.acceleration=v,e.area=d,e.density=h,e.electricCharge=p,e.electricCurrent=g,e.energy=C,e.force=y,e.length=S,e.mass=k,e.massFlow=U,e.power=q,e.pressure=F,e.pressureManometric=w,e.speed=_,e.standardVolumetricFlow=A,e.temperature=z,e.time=T,e.torque=I,e.viscosity=B,e.voltage=G,e.volume=j,e.volumetricFlow=O,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.d.ts
CHANGED
|
@@ -19,3 +19,4 @@ export { default as viscosity } from './units/viscosity';
|
|
|
19
19
|
export { default as voltage } from './units/voltage';
|
|
20
20
|
export { default as volume } from './units/volume';
|
|
21
21
|
export { default as volumetricFlow } from './units/volumetric-flow';
|
|
22
|
+
export { default as temperature } from './units/temperature';
|
package/dist/types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export type UnitsValues = {
|
|
2
2
|
name: string;
|
|
3
3
|
convertValue: number;
|
|
4
|
+
offset?: number;
|
|
4
5
|
};
|
|
5
6
|
export type VoltageUnits = {
|
|
6
7
|
V: UnitsValues;
|
|
@@ -166,6 +167,8 @@ export type TorqueUnits = {
|
|
|
166
167
|
'dyn/cm': UnitsValues;
|
|
167
168
|
'lbf/ft': UnitsValues;
|
|
168
169
|
'mN/m': UnitsValues;
|
|
170
|
+
'lbf/in': UnitsValues;
|
|
171
|
+
'ozf/in': UnitsValues;
|
|
169
172
|
};
|
|
170
173
|
export type Torque = {
|
|
171
174
|
baseUnit: 'N/m';
|
|
@@ -221,6 +224,13 @@ export type PressureUnits = {
|
|
|
221
224
|
'atm': UnitsValues;
|
|
222
225
|
'psi': UnitsValues;
|
|
223
226
|
'kg/cm2': UnitsValues;
|
|
227
|
+
'Pag': UnitsValues;
|
|
228
|
+
'kPag': UnitsValues;
|
|
229
|
+
'MPag': UnitsValues;
|
|
230
|
+
'barg': UnitsValues;
|
|
231
|
+
'atmg': UnitsValues;
|
|
232
|
+
'psig': UnitsValues;
|
|
233
|
+
'kg/cm2g': UnitsValues;
|
|
224
234
|
};
|
|
225
235
|
export type Pressure = {
|
|
226
236
|
baseUnit: 'Pa';
|
|
@@ -236,7 +246,7 @@ export type PressureManometricUnits = {
|
|
|
236
246
|
'kg/cm2g': UnitsValues;
|
|
237
247
|
};
|
|
238
248
|
export type PressureManometric = {
|
|
239
|
-
baseUnit: '
|
|
249
|
+
baseUnit: 'Pag';
|
|
240
250
|
units: PressureManometricUnits;
|
|
241
251
|
};
|
|
242
252
|
export type StandardVolumetricFlowUnits = {
|
|
@@ -246,12 +256,23 @@ export type StandardVolumetricFlowUnits = {
|
|
|
246
256
|
'MMSCMD': UnitsValues;
|
|
247
257
|
'MSCFD': UnitsValues;
|
|
248
258
|
'MMSCFD': UnitsValues;
|
|
259
|
+
'Sm3/h': UnitsValues;
|
|
260
|
+
'Sft3/h': UnitsValues;
|
|
249
261
|
};
|
|
250
262
|
export type StandardVolumetricFlow = {
|
|
251
263
|
baseUnit: 'SCMD';
|
|
252
264
|
units: StandardVolumetricFlowUnits;
|
|
253
265
|
};
|
|
254
|
-
export type
|
|
266
|
+
export type TemperatureUnits = {
|
|
267
|
+
'C': UnitsValues;
|
|
268
|
+
'F': UnitsValues;
|
|
269
|
+
'K': UnitsValues;
|
|
270
|
+
};
|
|
271
|
+
export type Temperature = {
|
|
272
|
+
baseUnit: 'C';
|
|
273
|
+
units: TemperatureUnits;
|
|
274
|
+
};
|
|
275
|
+
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;
|
|
255
276
|
export type MeasurementUnits<T extends Measurement> = T extends {
|
|
256
277
|
units: infer U;
|
|
257
278
|
} ? keyof U : never;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Temperature } from "../types";
|
|
2
|
+
declare const _default: (val: number) => {
|
|
3
|
+
readonly _internalConverter: import("../internalConverter").default<Temperature>;
|
|
4
|
+
from<U extends keyof import("../types").TemperatureUnits>(fromUnit: U): {
|
|
5
|
+
readonly _internalConverter: import("../internalConverter").default<Temperature>;
|
|
6
|
+
to<U_1 extends keyof import("../types").TemperatureUnits>(toUnit: U_1): number;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
package/package.json
CHANGED
|
@@ -1,51 +1,52 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
"scripts": {
|
|
32
|
-
"dev": "vite",
|
|
33
|
-
"build": "tsc && vite build",
|
|
34
|
-
"preview": "vite preview"
|
|
35
|
-
},
|
|
36
|
-
"devDependencies": {
|
|
37
|
-
"@typescript-eslint/eslint-plugin": "^6.13.1",
|
|
38
|
-
"eslint": "^8.55.0",
|
|
39
|
-
"eslint-config-standard-with-typescript": "^40.0.0",
|
|
40
|
-
"eslint-plugin-import": "^2.29.0",
|
|
41
|
-
"eslint-plugin-n": "^16.3.1",
|
|
42
|
-
"eslint-plugin-promise": "^6.1.1",
|
|
43
|
-
"typescript": "^5.3.2",
|
|
44
|
-
"vite": "^5.0.0",
|
|
45
|
-
"@changesets/cli": "^2.27.1",
|
|
46
|
-
"vite-plugin-dts": "^3.6.4"
|
|
47
|
-
},
|
|
48
|
-
"publishConfig": {
|
|
49
|
-
"access": "public"
|
|
2
|
+
"name": "engineering-unit-converter",
|
|
3
|
+
"repository": {
|
|
4
|
+
"type": "git",
|
|
5
|
+
"url": "git+https://github.com/alanhaertel/engineering-unit-converter.git"
|
|
6
|
+
},
|
|
7
|
+
"version": "0.0.10",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"units",
|
|
10
|
+
"engineering",
|
|
11
|
+
"unit manipulation",
|
|
12
|
+
"convert",
|
|
13
|
+
"metric",
|
|
14
|
+
"unit converter"
|
|
15
|
+
],
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"type": "module",
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"main": "./dist/engineering-unit-converter.umd.cjs",
|
|
22
|
+
"module": "./dist/engineering-unit-converter.js",
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": "./dist/engineering-unit-converter.js",
|
|
27
|
+
"require": "./dist/engineering-unit-converter.umd.cjs",
|
|
28
|
+
"types": "./dist/index.d.ts"
|
|
50
29
|
}
|
|
30
|
+
},
|
|
31
|
+
"scripts": {
|
|
32
|
+
"dev": "vite",
|
|
33
|
+
"build": "tsc && vite build",
|
|
34
|
+
"preview": "vite preview"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@changesets/cli": "^2.27.1",
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "^6.13.1",
|
|
39
|
+
"eslint": "^8.55.0",
|
|
40
|
+
"eslint-config-standard-with-typescript": "^40.0.0",
|
|
41
|
+
"eslint-plugin-import": "^2.29.0",
|
|
42
|
+
"eslint-plugin-n": "^16.3.1",
|
|
43
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
44
|
+
"typescript": "^5.3.2",
|
|
45
|
+
"vite": "^5.0.0",
|
|
46
|
+
"vite-plugin-dts": "^3.6.4",
|
|
47
|
+
"tsx": "^4.19.1"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
}
|
|
51
52
|
}
|