engineering-unit-converter 0.0.12 → 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: {
|
|
@@ -518,7 +518,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
518
518
|
// Conversion factor from Pa to psi
|
|
519
519
|
}
|
|
520
520
|
}
|
|
521
|
-
}, Y = n(
|
|
521
|
+
}, Y = n(k), y = {
|
|
522
522
|
baseUnit: "m/s",
|
|
523
523
|
units: {
|
|
524
524
|
"m/s": {
|
|
@@ -554,7 +554,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
554
554
|
convertValue: 2.23694
|
|
555
555
|
}
|
|
556
556
|
}
|
|
557
|
-
}, x = n(
|
|
557
|
+
}, x = n(y), K = {
|
|
558
558
|
baseUnit: "SCMD",
|
|
559
559
|
units: {
|
|
560
560
|
SCMD: {
|
|
@@ -597,7 +597,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
597
597
|
// Conversion factor from SCMD to MMSCFD
|
|
598
598
|
}
|
|
599
599
|
}
|
|
600
|
-
},
|
|
600
|
+
}, Q = n(K), U = {
|
|
601
601
|
baseUnit: "N/m",
|
|
602
602
|
units: {
|
|
603
603
|
"N/m": {
|
|
@@ -625,7 +625,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
625
625
|
convertValue: 10.945427
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
|
-
},
|
|
628
|
+
}, R = n(U), q = {
|
|
629
629
|
baseUnit: "sec",
|
|
630
630
|
units: {
|
|
631
631
|
sec: {
|
|
@@ -658,7 +658,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
658
658
|
// Conversion factor from seconds to days
|
|
659
659
|
}
|
|
660
660
|
}
|
|
661
|
-
},
|
|
661
|
+
}, X = n(q), F = {
|
|
662
662
|
baseUnit: "cP",
|
|
663
663
|
units: {
|
|
664
664
|
cP: {
|
|
@@ -686,7 +686,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
686
686
|
convertValue: 1 / 3.6
|
|
687
687
|
}
|
|
688
688
|
}
|
|
689
|
-
},
|
|
689
|
+
}, Z = n(F), w = {
|
|
690
690
|
baseUnit: "V",
|
|
691
691
|
// transform: (val) => val * baseValue,
|
|
692
692
|
units: {
|
|
@@ -703,7 +703,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
703
703
|
convertValue: 1e3
|
|
704
704
|
}
|
|
705
705
|
}
|
|
706
|
-
},
|
|
706
|
+
}, ee = n(w), $ = {
|
|
707
707
|
baseUnit: "m3",
|
|
708
708
|
units: {
|
|
709
709
|
m3: {
|
|
@@ -731,7 +731,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
731
731
|
convertValue: 1 / 879.877
|
|
732
732
|
}
|
|
733
733
|
}
|
|
734
|
-
},
|
|
734
|
+
}, ne = n($), _ = {
|
|
735
735
|
baseUnit: "m3/h",
|
|
736
736
|
units: {
|
|
737
737
|
"m3/h": {
|
|
@@ -771,7 +771,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
771
771
|
convertValue: 378541e-8 * 3600
|
|
772
772
|
}
|
|
773
773
|
}
|
|
774
|
-
},
|
|
774
|
+
}, ae = n(_), D = {
|
|
775
775
|
baseUnit: "C",
|
|
776
776
|
units: {
|
|
777
777
|
C: {
|
|
@@ -792,28 +792,118 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
792
792
|
// Subtract 273.15 to convert from K to C
|
|
793
793
|
}
|
|
794
794
|
}
|
|
795
|
-
},
|
|
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);
|
|
796
885
|
export {
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
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,
|
|
805
894
|
j as mass,
|
|
806
895
|
O as massFlow,
|
|
807
896
|
z as power,
|
|
808
897
|
Y as pressure,
|
|
809
898
|
E as pressureManometric,
|
|
899
|
+
re as pressurePerLength,
|
|
810
900
|
x as speed,
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
901
|
+
Q as standardVolumetricFlow,
|
|
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
|
|
819
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 L=Object.defineProperty;var Q=(e,t,o)=>t in e?L(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var u=(e,t,o)=>(Q(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={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(F),_={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(_),A={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}}},I=n(A),N=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),G={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(G),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}}},z=n(J),E={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}}},Y=n(E);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=$,e.pressureManometric=w,e.speed=D,e.standardVolumetricFlow=I,e.temperature=Y,e.time=B,e.torque=N,e.viscosity=W,e.voltage=j,e.volume=O,e.volumetricFlow=z,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
|
@@ -243,6 +243,28 @@ export type Pressure = {
|
|
|
243
243
|
baseUnit: 'Pa';
|
|
244
244
|
units: PressureUnits;
|
|
245
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
|
+
};
|
|
246
268
|
export type PressureManometricUnits = {
|
|
247
269
|
'Pag': UnitsValues;
|
|
248
270
|
'kPag': UnitsValues;
|
|
@@ -279,7 +301,7 @@ export type Temperature = {
|
|
|
279
301
|
baseUnit: 'C';
|
|
280
302
|
units: TemperatureUnits;
|
|
281
303
|
};
|
|
282
|
-
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;
|
|
283
305
|
export type MeasurementUnits<T extends Measurement> = T extends {
|
|
284
306
|
units: infer U;
|
|
285
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;
|