engineering-unit-converter 0.0.10 → 0.0.12
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.
|
@@ -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
|
-
}, G = n(d),
|
|
169
|
+
}, G = n(d), 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
|
-
}, T = n(
|
|
197
|
+
}, T = n(h), f = {
|
|
198
198
|
baseUnit: "J",
|
|
199
199
|
units: {
|
|
200
200
|
J: {
|
|
@@ -232,7 +232,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
232
232
|
// Conversion factor from J to BTU
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
|
-
}, W = n(
|
|
235
|
+
}, W = n(f), g = {
|
|
236
236
|
baseUnit: "N",
|
|
237
237
|
units: {
|
|
238
238
|
N: {
|
|
@@ -262,6 +262,10 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
262
262
|
name: "Meter",
|
|
263
263
|
convertValue: 1
|
|
264
264
|
},
|
|
265
|
+
km: {
|
|
266
|
+
name: "Kilometer",
|
|
267
|
+
convertValue: 1e3
|
|
268
|
+
},
|
|
265
269
|
mm: {
|
|
266
270
|
name: "Millimeter",
|
|
267
271
|
convertValue: 1e-3
|
|
@@ -281,6 +285,14 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
281
285
|
name: "Foot",
|
|
282
286
|
convertValue: 0.3048
|
|
283
287
|
// Conversion factor from m to ft
|
|
288
|
+
},
|
|
289
|
+
um: {
|
|
290
|
+
name: "Micrometer",
|
|
291
|
+
convertValue: 1e-6
|
|
292
|
+
},
|
|
293
|
+
nm: {
|
|
294
|
+
name: "Nanometer",
|
|
295
|
+
convertValue: 1e-9
|
|
284
296
|
}
|
|
285
297
|
}
|
|
286
298
|
}, J = n(b), C = {
|
|
@@ -499,9 +511,14 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
499
511
|
convertValue: 98066.5,
|
|
500
512
|
offset: -1
|
|
501
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
|
|
502
519
|
}
|
|
503
520
|
}
|
|
504
|
-
},
|
|
521
|
+
}, Y = n(P), U = {
|
|
505
522
|
baseUnit: "m/s",
|
|
506
523
|
units: {
|
|
507
524
|
"m/s": {
|
|
@@ -531,9 +548,13 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
531
548
|
"ft/h": {
|
|
532
549
|
name: "Foot per hour",
|
|
533
550
|
convertValue: 1 / 11811
|
|
551
|
+
},
|
|
552
|
+
mph: {
|
|
553
|
+
name: "Miles per hour",
|
|
554
|
+
convertValue: 2.23694
|
|
534
555
|
}
|
|
535
556
|
}
|
|
536
|
-
},
|
|
557
|
+
}, x = n(U), k = {
|
|
537
558
|
baseUnit: "SCMD",
|
|
538
559
|
units: {
|
|
539
560
|
SCMD: {
|
|
@@ -576,7 +597,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
576
597
|
// Conversion factor from SCMD to MMSCFD
|
|
577
598
|
}
|
|
578
599
|
}
|
|
579
|
-
},
|
|
600
|
+
}, L = n(k), K = {
|
|
580
601
|
baseUnit: "N/m",
|
|
581
602
|
units: {
|
|
582
603
|
"N/m": {
|
|
@@ -604,10 +625,10 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
604
625
|
convertValue: 10.945427
|
|
605
626
|
}
|
|
606
627
|
}
|
|
607
|
-
},
|
|
608
|
-
baseUnit: "
|
|
628
|
+
}, Q = n(K), q = {
|
|
629
|
+
baseUnit: "sec",
|
|
609
630
|
units: {
|
|
610
|
-
|
|
631
|
+
sec: {
|
|
611
632
|
name: "Second",
|
|
612
633
|
convertValue: 1
|
|
613
634
|
},
|
|
@@ -625,9 +646,19 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
625
646
|
name: "Day",
|
|
626
647
|
convertValue: 86400
|
|
627
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
|
|
628
659
|
}
|
|
629
660
|
}
|
|
630
|
-
}, R = n(
|
|
661
|
+
}, R = n(q), w = {
|
|
631
662
|
baseUnit: "cP",
|
|
632
663
|
units: {
|
|
633
664
|
cP: {
|
|
@@ -655,7 +686,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
655
686
|
convertValue: 1 / 3.6
|
|
656
687
|
}
|
|
657
688
|
}
|
|
658
|
-
}, X = n(
|
|
689
|
+
}, X = n(w), F = {
|
|
659
690
|
baseUnit: "V",
|
|
660
691
|
// transform: (val) => val * baseValue,
|
|
661
692
|
units: {
|
|
@@ -774,13 +805,13 @@ export {
|
|
|
774
805
|
j as mass,
|
|
775
806
|
O as massFlow,
|
|
776
807
|
z as power,
|
|
777
|
-
|
|
808
|
+
Y as pressure,
|
|
778
809
|
E as pressureManometric,
|
|
779
|
-
|
|
780
|
-
|
|
810
|
+
x as speed,
|
|
811
|
+
L as standardVolumetricFlow,
|
|
781
812
|
ae as temperature,
|
|
782
813
|
R as time,
|
|
783
|
-
|
|
814
|
+
Q as torque,
|
|
784
815
|
X as viscosity,
|
|
785
816
|
Z as voltage,
|
|
786
817
|
ee as volume,
|
|
@@ -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 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"})});
|
package/dist/types.d.ts
CHANGED
|
@@ -68,10 +68,13 @@ export type Viscosity = {
|
|
|
68
68
|
};
|
|
69
69
|
export type LengthUnits = {
|
|
70
70
|
mm: UnitsValues;
|
|
71
|
+
km: UnitsValues;
|
|
71
72
|
cm: UnitsValues;
|
|
72
73
|
m: UnitsValues;
|
|
73
74
|
in: UnitsValues;
|
|
74
75
|
ft: UnitsValues;
|
|
76
|
+
um: UnitsValues;
|
|
77
|
+
nm: UnitsValues;
|
|
75
78
|
};
|
|
76
79
|
export type Length = {
|
|
77
80
|
baseUnit: 'm';
|
|
@@ -96,6 +99,7 @@ export type SpeedUnits = {
|
|
|
96
99
|
'knot': UnitsValues;
|
|
97
100
|
'm/h': UnitsValues;
|
|
98
101
|
'ft/h': UnitsValues;
|
|
102
|
+
'mph': UnitsValues;
|
|
99
103
|
};
|
|
100
104
|
export type Speed = {
|
|
101
105
|
baseUnit: 'm/s';
|
|
@@ -175,13 +179,15 @@ export type Torque = {
|
|
|
175
179
|
units: TorqueUnits;
|
|
176
180
|
};
|
|
177
181
|
export type TimeUnits = {
|
|
178
|
-
'
|
|
182
|
+
'sec': UnitsValues;
|
|
179
183
|
'min': UnitsValues;
|
|
180
184
|
'hr': UnitsValues;
|
|
181
185
|
'day': UnitsValues;
|
|
186
|
+
'month': UnitsValues;
|
|
187
|
+
'year': UnitsValues;
|
|
182
188
|
};
|
|
183
189
|
export type Time = {
|
|
184
|
-
baseUnit: '
|
|
190
|
+
baseUnit: 'sec';
|
|
185
191
|
units: TimeUnits;
|
|
186
192
|
};
|
|
187
193
|
export type ElectricChargeUnits = {
|
|
@@ -223,6 +229,7 @@ export type PressureUnits = {
|
|
|
223
229
|
'bar': UnitsValues;
|
|
224
230
|
'atm': UnitsValues;
|
|
225
231
|
'psi': UnitsValues;
|
|
232
|
+
'ksi': UnitsValues;
|
|
226
233
|
'kg/cm2': UnitsValues;
|
|
227
234
|
'Pag': UnitsValues;
|
|
228
235
|
'kPag': UnitsValues;
|