engineering-unit-converter 0.0.11 → 0.0.13
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,7 +1,7 @@
|
|
|
1
1
|
var l = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var c = (t, e, a) => (
|
|
4
|
-
class
|
|
2
|
+
var m = (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) => (m(t, typeof e != "symbol" ? e + "" : e, a), a);
|
|
4
|
+
class u {
|
|
5
5
|
constructor(e, a) {
|
|
6
6
|
c(this, "_definitions");
|
|
7
7
|
c(this, "_val");
|
|
@@ -32,7 +32,7 @@ class m {
|
|
|
32
32
|
class s {
|
|
33
33
|
constructor(e, a) {
|
|
34
34
|
c(this, "_internalConverter");
|
|
35
|
-
this._internalConverter = new
|
|
35
|
+
this._internalConverter = new u(e, a);
|
|
36
36
|
}
|
|
37
37
|
from(e) {
|
|
38
38
|
return this._internalConverter.from(e), new i(this._internalConverter);
|
|
@@ -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
|
+
}, G = n(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
|
+
}, B = n(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
|
+
}, N = n(p), f = {
|
|
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
|
+
}, T = n(f), h = {
|
|
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
|
+
}, W = n(h), d = {
|
|
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
|
+
}, H = n(d), g = {
|
|
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
|
+
}, J = n(g), 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
|
+
}, L = n(b), C = {
|
|
299
299
|
baseUnit: "kg/s",
|
|
300
300
|
units: {
|
|
301
301
|
"kg/s": {
|
|
@@ -368,7 +368,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
368
368
|
// Conversion factor from kg to ton
|
|
369
369
|
}
|
|
370
370
|
}
|
|
371
|
-
}, j = n(M),
|
|
371
|
+
}, j = n(M), P = {
|
|
372
372
|
baseUnit: "W",
|
|
373
373
|
units: {
|
|
374
374
|
W: {
|
|
@@ -396,7 +396,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
396
396
|
// Conversion factor from W to cal/s
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
|
-
}, z = n(
|
|
399
|
+
}, z = n(P), S = {
|
|
400
400
|
baseUnit: "Pag",
|
|
401
401
|
units: {
|
|
402
402
|
Pag: {
|
|
@@ -434,7 +434,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
434
434
|
// Conversion factor from Pa to kg/cm²
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
|
-
}, E = n(
|
|
437
|
+
}, E = n(S), k = {
|
|
438
438
|
baseUnit: "Pa",
|
|
439
439
|
units: {
|
|
440
440
|
Pa: {
|
|
@@ -511,9 +511,14 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
511
511
|
convertValue: 98066.5,
|
|
512
512
|
offset: -1
|
|
513
513
|
// Conversion factor from Pa to kg/cm²
|
|
514
|
+
},
|
|
515
|
+
ksi: {
|
|
516
|
+
name: "1000 Pound per Square Inch",
|
|
517
|
+
convertValue: 6894.76 * 1e3
|
|
518
|
+
// Conversion factor from Pa to psi
|
|
514
519
|
}
|
|
515
520
|
}
|
|
516
|
-
},
|
|
521
|
+
}, Y = n(k), y = {
|
|
517
522
|
baseUnit: "m/s",
|
|
518
523
|
units: {
|
|
519
524
|
"m/s": {
|
|
@@ -549,7 +554,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
549
554
|
convertValue: 2.23694
|
|
550
555
|
}
|
|
551
556
|
}
|
|
552
|
-
},
|
|
557
|
+
}, x = n(y), K = {
|
|
553
558
|
baseUnit: "SCMD",
|
|
554
559
|
units: {
|
|
555
560
|
SCMD: {
|
|
@@ -592,7 +597,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
592
597
|
// Conversion factor from SCMD to MMSCFD
|
|
593
598
|
}
|
|
594
599
|
}
|
|
595
|
-
}, Q = n(
|
|
600
|
+
}, Q = n(K), U = {
|
|
596
601
|
baseUnit: "N/m",
|
|
597
602
|
units: {
|
|
598
603
|
"N/m": {
|
|
@@ -620,10 +625,10 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
620
625
|
convertValue: 10.945427
|
|
621
626
|
}
|
|
622
627
|
}
|
|
623
|
-
},
|
|
624
|
-
baseUnit: "
|
|
628
|
+
}, R = n(U), q = {
|
|
629
|
+
baseUnit: "sec",
|
|
625
630
|
units: {
|
|
626
|
-
|
|
631
|
+
sec: {
|
|
627
632
|
name: "Second",
|
|
628
633
|
convertValue: 1
|
|
629
634
|
},
|
|
@@ -641,9 +646,19 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
641
646
|
name: "Day",
|
|
642
647
|
convertValue: 86400
|
|
643
648
|
// Conversion factor from seconds to days
|
|
649
|
+
},
|
|
650
|
+
month: {
|
|
651
|
+
name: "Month",
|
|
652
|
+
convertValue: 86400 * 30
|
|
653
|
+
// Conversion factor from seconds to days
|
|
654
|
+
},
|
|
655
|
+
year: {
|
|
656
|
+
name: "Year",
|
|
657
|
+
convertValue: 86400 * 365
|
|
658
|
+
// Conversion factor from seconds to days
|
|
644
659
|
}
|
|
645
660
|
}
|
|
646
|
-
},
|
|
661
|
+
}, X = n(q), F = {
|
|
647
662
|
baseUnit: "cP",
|
|
648
663
|
units: {
|
|
649
664
|
cP: {
|
|
@@ -671,7 +686,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
671
686
|
convertValue: 1 / 3.6
|
|
672
687
|
}
|
|
673
688
|
}
|
|
674
|
-
},
|
|
689
|
+
}, Z = n(F), w = {
|
|
675
690
|
baseUnit: "V",
|
|
676
691
|
// transform: (val) => val * baseValue,
|
|
677
692
|
units: {
|
|
@@ -688,7 +703,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
688
703
|
convertValue: 1e3
|
|
689
704
|
}
|
|
690
705
|
}
|
|
691
|
-
},
|
|
706
|
+
}, ee = n(w), $ = {
|
|
692
707
|
baseUnit: "m3",
|
|
693
708
|
units: {
|
|
694
709
|
m3: {
|
|
@@ -716,7 +731,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
716
731
|
convertValue: 1 / 879.877
|
|
717
732
|
}
|
|
718
733
|
}
|
|
719
|
-
},
|
|
734
|
+
}, ne = n($), _ = {
|
|
720
735
|
baseUnit: "m3/h",
|
|
721
736
|
units: {
|
|
722
737
|
"m3/h": {
|
|
@@ -756,7 +771,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
756
771
|
convertValue: 378541e-8 * 3600
|
|
757
772
|
}
|
|
758
773
|
}
|
|
759
|
-
},
|
|
774
|
+
}, ae = n(_), D = {
|
|
760
775
|
baseUnit: "C",
|
|
761
776
|
units: {
|
|
762
777
|
C: {
|
|
@@ -777,28 +792,118 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
777
792
|
// Subtract 273.15 to convert from K to C
|
|
778
793
|
}
|
|
779
794
|
}
|
|
780
|
-
},
|
|
795
|
+
}, te = n(D), I = {
|
|
796
|
+
baseUnit: "Pa/m",
|
|
797
|
+
units: {
|
|
798
|
+
"Pa/m": {
|
|
799
|
+
name: "Pascal per Meter",
|
|
800
|
+
convertValue: 1
|
|
801
|
+
},
|
|
802
|
+
"Pa/km": {
|
|
803
|
+
name: "Pascal per Kilometer",
|
|
804
|
+
convertValue: 1 / 1e3
|
|
805
|
+
// 1 km = 1000 m
|
|
806
|
+
},
|
|
807
|
+
"kPa/m": {
|
|
808
|
+
name: "Kilopascal per Meter",
|
|
809
|
+
convertValue: 1e3
|
|
810
|
+
// 1 kPa = 1000 Pa
|
|
811
|
+
},
|
|
812
|
+
"bar/m": {
|
|
813
|
+
name: "Bar per Meter",
|
|
814
|
+
convertValue: 1e5
|
|
815
|
+
// 1 bar = 100,000 Pa
|
|
816
|
+
},
|
|
817
|
+
"bar/km": {
|
|
818
|
+
name: "Bar per Kilometer",
|
|
819
|
+
convertValue: 100
|
|
820
|
+
// 1 bar/km = 1e5 Pa / 1000 m
|
|
821
|
+
},
|
|
822
|
+
"psi/ft": {
|
|
823
|
+
name: "Pound per Square Inch per Foot",
|
|
824
|
+
convertValue: 6894.76 / 3.28084
|
|
825
|
+
// 1 psi = 6894.76 Pa, 1 ft = 0.3048 m
|
|
826
|
+
},
|
|
827
|
+
"psi/m": {
|
|
828
|
+
name: "Pound per Square Inch per Meter",
|
|
829
|
+
convertValue: 6894.76
|
|
830
|
+
// 1 psi = 6894.76 Pa
|
|
831
|
+
},
|
|
832
|
+
"atm/m": {
|
|
833
|
+
name: "Atmosphere per Meter",
|
|
834
|
+
convertValue: 101325
|
|
835
|
+
// 1 atm = 101325 Pa
|
|
836
|
+
},
|
|
837
|
+
"atm/km": {
|
|
838
|
+
name: "Atmosphere per Kilometer",
|
|
839
|
+
convertValue: 101.325
|
|
840
|
+
// 1 atm/km = 101325 Pa / 1000 m
|
|
841
|
+
},
|
|
842
|
+
"kg/cm2/m": {
|
|
843
|
+
name: "Kilogram per Square Centimeter per Meter",
|
|
844
|
+
convertValue: 98066.5
|
|
845
|
+
// 1 kg/cm² = 98066.5 Pa
|
|
846
|
+
},
|
|
847
|
+
"kg/cm2/km": {
|
|
848
|
+
name: "Kilogram per Square Centimeter per Kilometer",
|
|
849
|
+
convertValue: 98.0665
|
|
850
|
+
// 1 kg/cm² = 98066.5 Pa / 1000 m
|
|
851
|
+
},
|
|
852
|
+
// Gauge Units with Atmospheric Offset
|
|
853
|
+
"barg/m": {
|
|
854
|
+
name: "Bar Gauge per Meter",
|
|
855
|
+
convertValue: 1e5,
|
|
856
|
+
offset: -101325
|
|
857
|
+
// Remove atmospheric pressure
|
|
858
|
+
},
|
|
859
|
+
"psig/ft": {
|
|
860
|
+
name: "Pound per Square Inch Gauge per Foot",
|
|
861
|
+
convertValue: 6894.76 / 3.28084,
|
|
862
|
+
offset: -101325
|
|
863
|
+
// Remove atmospheric pressure in Pa
|
|
864
|
+
},
|
|
865
|
+
"psig/m": {
|
|
866
|
+
name: "Pound per Square Inch Gauge per Meter",
|
|
867
|
+
convertValue: 6894.76,
|
|
868
|
+
offset: -101325
|
|
869
|
+
// Remove atmospheric pressure in Pa
|
|
870
|
+
},
|
|
871
|
+
"kg/cm2g/m": {
|
|
872
|
+
name: "Kilogram per Square Centimeter Gauge per Meter",
|
|
873
|
+
convertValue: 98066.5,
|
|
874
|
+
offset: -101325
|
|
875
|
+
// Remove atmospheric pressure in Pa
|
|
876
|
+
},
|
|
877
|
+
"kg/cm2g/km": {
|
|
878
|
+
name: "Kilogram per Square Centimeter Gauge per Kilometer",
|
|
879
|
+
convertValue: 98.0665,
|
|
880
|
+
offset: -101.325
|
|
881
|
+
// Remove atmospheric pressure divided by 1000
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
}, re = n(I);
|
|
781
885
|
export {
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
886
|
+
G as acceleration,
|
|
887
|
+
B as area,
|
|
888
|
+
N as density,
|
|
889
|
+
T as electricCharge,
|
|
890
|
+
W as electricCurrent,
|
|
891
|
+
H as energy,
|
|
892
|
+
J as force,
|
|
893
|
+
L as length,
|
|
790
894
|
j as mass,
|
|
791
895
|
O as massFlow,
|
|
792
896
|
z as power,
|
|
793
|
-
|
|
897
|
+
Y as pressure,
|
|
794
898
|
E as pressureManometric,
|
|
795
|
-
|
|
899
|
+
re as pressurePerLength,
|
|
900
|
+
x as speed,
|
|
796
901
|
Q as standardVolumetricFlow,
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
902
|
+
te as temperature,
|
|
903
|
+
X as time,
|
|
904
|
+
R as torque,
|
|
905
|
+
Z as viscosity,
|
|
906
|
+
ee as voltage,
|
|
907
|
+
ne as volume,
|
|
908
|
+
ae as volumetricFlow
|
|
804
909
|
};
|
|
@@ -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 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},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}}}),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},mph:{name:"Miles per hour",convertValue:2.23694}}},_=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}}}),N=n({baseUnit:"s",units:{s:{name:"Second",convertValue:1},min:{name:"Minute",convertValue:60},hr:{name:"Hour",convertValue:3600},day:{name:"Day",convertValue:86400}}}),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}}},B=n(T),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=N,e.torque=I,e.viscosity=B,e.voltage=G,e.volume=j,e.volumetricFlow=O,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 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}}}),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}}},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},"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"})});
|
package/dist/index.d.ts
CHANGED
|
@@ -20,3 +20,4 @@ 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
22
|
export { default as temperature } from './units/temperature';
|
|
23
|
+
export { default as pressurePerLength } from './units/pressure-per-length';
|
package/dist/types.d.ts
CHANGED
|
@@ -179,13 +179,15 @@ export type Torque = {
|
|
|
179
179
|
units: TorqueUnits;
|
|
180
180
|
};
|
|
181
181
|
export type TimeUnits = {
|
|
182
|
-
'
|
|
182
|
+
'sec': UnitsValues;
|
|
183
183
|
'min': UnitsValues;
|
|
184
184
|
'hr': UnitsValues;
|
|
185
185
|
'day': UnitsValues;
|
|
186
|
+
'month': UnitsValues;
|
|
187
|
+
'year': UnitsValues;
|
|
186
188
|
};
|
|
187
189
|
export type Time = {
|
|
188
|
-
baseUnit: '
|
|
190
|
+
baseUnit: 'sec';
|
|
189
191
|
units: TimeUnits;
|
|
190
192
|
};
|
|
191
193
|
export type ElectricChargeUnits = {
|
|
@@ -227,6 +229,7 @@ export type PressureUnits = {
|
|
|
227
229
|
'bar': UnitsValues;
|
|
228
230
|
'atm': UnitsValues;
|
|
229
231
|
'psi': UnitsValues;
|
|
232
|
+
'ksi': UnitsValues;
|
|
230
233
|
'kg/cm2': UnitsValues;
|
|
231
234
|
'Pag': UnitsValues;
|
|
232
235
|
'kPag': UnitsValues;
|
|
@@ -240,6 +243,28 @@ export type Pressure = {
|
|
|
240
243
|
baseUnit: 'Pa';
|
|
241
244
|
units: PressureUnits;
|
|
242
245
|
};
|
|
246
|
+
export type PressurePerLengthUnits = {
|
|
247
|
+
'Pa/m': UnitsValues;
|
|
248
|
+
'Pa/km': UnitsValues;
|
|
249
|
+
'kPa/m': UnitsValues;
|
|
250
|
+
'bar/m': UnitsValues;
|
|
251
|
+
'bar/km': UnitsValues;
|
|
252
|
+
'psi/m': UnitsValues;
|
|
253
|
+
'psi/ft': UnitsValues;
|
|
254
|
+
'atm/m': UnitsValues;
|
|
255
|
+
'atm/km': UnitsValues;
|
|
256
|
+
'kg/cm2/m': UnitsValues;
|
|
257
|
+
'kg/cm2/km': UnitsValues;
|
|
258
|
+
'barg/m': UnitsValues;
|
|
259
|
+
'psig/m': UnitsValues;
|
|
260
|
+
'psig/ft': UnitsValues;
|
|
261
|
+
'kg/cm2g/m': UnitsValues;
|
|
262
|
+
'kg/cm2g/km': UnitsValues;
|
|
263
|
+
};
|
|
264
|
+
export type PressurePerLength = {
|
|
265
|
+
baseUnit: 'Pa/m';
|
|
266
|
+
units: PressurePerLengthUnits;
|
|
267
|
+
};
|
|
243
268
|
export type PressureManometricUnits = {
|
|
244
269
|
'Pag': UnitsValues;
|
|
245
270
|
'kPag': UnitsValues;
|
|
@@ -276,7 +301,7 @@ export type Temperature = {
|
|
|
276
301
|
baseUnit: 'C';
|
|
277
302
|
units: TemperatureUnits;
|
|
278
303
|
};
|
|
279
|
-
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;
|
|
304
|
+
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;
|
|
280
305
|
export type MeasurementUnits<T extends Measurement> = T extends {
|
|
281
306
|
units: infer U;
|
|
282
307
|
} ? keyof U : never;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type PressurePerLength } from '../types';
|
|
2
|
+
declare const _default: (val: number) => {
|
|
3
|
+
readonly _internalConverter: import("../internalConverter").default<PressurePerLength>;
|
|
4
|
+
from<U extends keyof import("../types").PressurePerLengthUnits>(fromUnit: U): {
|
|
5
|
+
readonly _internalConverter: import("../internalConverter").default<PressurePerLength>;
|
|
6
|
+
to<U_1 extends keyof import("../types").PressurePerLengthUnits>(toUnit: U_1): number;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|