engineering-unit-converter 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,11 +18,10 @@ Usage
18
18
 
19
19
  Using this library is simple, the above snippet shows an example:
20
20
 
21
-
22
21
  ```js
23
22
  import { massFlow } from 'engineering-unit-converter'
24
23
  const newValue = massFlow(65000).from('lb/day').to('kg/h')
25
- console.log(newValue) //1.2284783333333333
24
+ console.log(newValue) //1228.4818798922718
26
25
  ```
27
26
 
28
27
  Available units
@@ -45,31 +45,23 @@ class s {
45
45
  }
46
46
  }
47
47
  const n = (t) => (e) => new m(e, t), i = {
48
- baseUnit: "m/",
48
+ baseUnit: "m/s2",
49
49
  units: {
50
- "m/": {
50
+ "m/s2": {
51
51
  name: "Meter per Second Squared",
52
52
  convertValue: 1
53
53
  },
54
- "km/": {
54
+ "km/s2": {
55
55
  name: "Kilometer per Second Squared",
56
- convertValue: 1e6
57
- // Conversion factor from m/s² to km/s²
56
+ convertValue: 1e3
58
57
  },
59
- "cm/": {
58
+ "cm/s2": {
60
59
  name: "Centimeter per Second Squared",
61
- convertValue: 1e-4
62
- // Conversion factor from m/s² to cm/s²
63
- },
64
- g: {
65
- name: "Gravity",
66
- convertValue: 9.80665
67
- // Standard gravity on Earth, in m/s²
60
+ convertValue: 1 / 100
68
61
  },
69
- "ft/": {
62
+ "ft/s2": {
70
63
  name: "Foot per Second Squared",
71
- convertValue: 0.3048
72
- // Conversion factor from m/s² to ft/s²
64
+ convertValue: 1 / 3.28084
73
65
  }
74
66
  }
75
67
  }, A = n(i), v = {
@@ -101,12 +93,12 @@ const n = (t) => (e) => new m(e, t), i = {
101
93
  },
102
94
  sqft: {
103
95
  name: "Square Foot",
104
- convertValue: 1 / 10.7639
96
+ convertValue: 1 / 10.763888889
105
97
  // Conversion factor from m2 to sqft
106
98
  },
107
99
  sqyd: {
108
100
  name: "Square Yard",
109
- convertValue: 1 / 1.19599
101
+ convertValue: 1 / 1.1959876543333339
110
102
  // Conversion factor from m2 to sqyd
111
103
  },
112
104
  acre: {
@@ -120,7 +112,7 @@ const n = (t) => (e) => new m(e, t), i = {
120
112
  // Conversion factor from m2 to hectare
121
113
  }
122
114
  }
123
- }, T = n(v), V = {
115
+ }, N = n(v), V = {
124
116
  baseUnit: "kg/m3",
125
117
  units: {
126
118
  "kg/m3": {
@@ -129,26 +121,22 @@ const n = (t) => (e) => new m(e, t), i = {
129
121
  },
130
122
  "lb/ft3": {
131
123
  name: "Pound per cubic foot",
132
- convertValue: 0.0160185
133
- // Conversion factor from kg/m3 to lb/ft3
124
+ convertValue: 1 / 0.062427962
134
125
  },
135
126
  "g/cm3": {
136
127
  name: "Gram per cubic centimeter",
137
128
  convertValue: 1e-3
138
- // Conversion factor from kg/m3 to g/cm3
139
129
  },
140
130
  "kg/ft3": {
141
131
  name: "Kilogram per cubic foot",
142
- convertValue: 1 / 16.0185
143
- // Conversion factor from lb/ft3 to kg/ft3
132
+ convertValue: 1 / 0.0283168
144
133
  },
145
134
  "lb/m3": {
146
135
  name: "Pound per cubic meter",
147
- convertValue: 0.0160185 / 1e3
148
- // Conversion factor from lb/ft³ to lb/m³
136
+ convertValue: 1 / 2.20462
149
137
  }
150
138
  }
151
- }, N = n(V), p = {
139
+ }, G = n(V), p = {
152
140
  baseUnit: "C",
153
141
  units: {
154
142
  C: {
@@ -176,7 +164,7 @@ const n = (t) => (e) => new m(e, t), i = {
176
164
  // Conversion factor from C to pC
177
165
  }
178
166
  }
179
- }, G = n(p), d = {
167
+ }, I = n(p), d = {
180
168
  baseUnit: "A",
181
169
  units: {
182
170
  A: {
@@ -204,7 +192,7 @@ const n = (t) => (e) => new m(e, t), i = {
204
192
  // Conversion factor from A to pA
205
193
  }
206
194
  }
207
- }, I = n(d), h = {
195
+ }, T = n(d), h = {
208
196
  baseUnit: "J",
209
197
  units: {
210
198
  J: {
@@ -256,7 +244,7 @@ const n = (t) => (e) => new m(e, t), i = {
256
244
  },
257
245
  lbf: {
258
246
  name: "Pound-force",
259
- convertValue: 4.44822
247
+ convertValue: 1 / 0.224809
260
248
  // Conversion factor from N to lbf
261
249
  },
262
250
  kgf: {
@@ -265,9 +253,13 @@ const n = (t) => (e) => new m(e, t), i = {
265
253
  // Conversion factor from N to kgf
266
254
  }
267
255
  }
268
- }, B = n(b), g = {
256
+ }, B = n(b), C = {
269
257
  baseUnit: "m",
270
258
  units: {
259
+ m: {
260
+ name: "Meter",
261
+ convertValue: 1
262
+ },
271
263
  mm: {
272
264
  name: "Millimeter",
273
265
  convertValue: 1e-3
@@ -278,10 +270,6 @@ const n = (t) => (e) => new m(e, t), i = {
278
270
  convertValue: 0.01
279
271
  // Conversion factor from m to cm
280
272
  },
281
- m: {
282
- name: "Meter",
283
- convertValue: 1
284
- },
285
273
  in: {
286
274
  name: "Inch",
287
275
  convertValue: 0.0254
@@ -293,7 +281,7 @@ const n = (t) => (e) => new m(e, t), i = {
293
281
  // Conversion factor from m to ft
294
282
  }
295
283
  }
296
- }, J = n(g), C = {
284
+ }, J = n(C), g = {
297
285
  baseUnit: "kg/s",
298
286
  units: {
299
287
  "kg/s": {
@@ -303,12 +291,10 @@ const n = (t) => (e) => new m(e, t), i = {
303
291
  "kg/h": {
304
292
  name: "Kilogram per hour",
305
293
  convertValue: 1 / 3600
306
- // 1 hour = 3600 seconds
307
294
  },
308
295
  "lb/day": {
309
296
  name: "Pound per day",
310
- convertValue: 453592e-9 * (1 / 86400)
311
- // 1 lb = 0.000453592 kg, 1 day = 86400 seconds
297
+ convertValue: 1 / 190479
312
298
  },
313
299
  "g/s": {
314
300
  name: "Gram per second",
@@ -316,27 +302,23 @@ const n = (t) => (e) => new m(e, t), i = {
316
302
  },
317
303
  "lb/h": {
318
304
  name: "Pound per hour",
319
- convertValue: 453592e-9
305
+ convertValue: 1 / (190479 / 24)
320
306
  },
321
307
  "ton/day": {
322
308
  name: "Ton per day",
323
- convertValue: 1e3 * (1 / 86400)
324
- // 1 ton = 1000 kg
309
+ convertValue: 1 / (34762.5 / 365)
325
310
  },
326
311
  "oz/min": {
327
312
  name: "Ounce per minute",
328
- convertValue: 0.0283495 / 60
329
- // 1 oz = 0.0283495 kg, 1 minute = 60 seconds
313
+ convertValue: 1 / 2116.4394433764
330
314
  },
331
315
  "ton/year": {
332
316
  name: "Ton per year",
333
- // Adjust the name as needed
334
- convertValue: 1e3 / 86400 / 365
335
- // Assuming 1 ton/year = 1000 kg / 86400 seconds / 365 days
317
+ convertValue: 1 / 34762.5
336
318
  },
337
319
  "lb/s": {
338
320
  name: "Pound per second",
339
- convertValue: 453592e-9
321
+ convertValue: 1 / (190479 / 86400)
340
322
  },
341
323
  "kg/day": {
342
324
  name: "Kilogram per day",
@@ -344,7 +326,7 @@ const n = (t) => (e) => new m(e, t), i = {
344
326
  // 1 day = 86400 seconds
345
327
  }
346
328
  }
347
- }, j = n(C), f = {
329
+ }, j = n(g), f = {
348
330
  baseUnit: "kg",
349
331
  units: {
350
332
  kg: {
@@ -391,12 +373,12 @@ const n = (t) => (e) => new m(e, t), i = {
391
373
  },
392
374
  "BTU/h": {
393
375
  name: "British Thermal Unit per hour",
394
- convertValue: 3.41214
376
+ convertValue: 1 / 3.41214
395
377
  // Conversion factor from W to BTU/h
396
378
  },
397
379
  "cal/s": {
398
380
  name: "Calorie per second",
399
- convertValue: 239.006
381
+ convertValue: 1 / 0.23884589662749595
400
382
  // Conversion factor from W to cal/s
401
383
  }
402
384
  }
@@ -486,32 +468,26 @@ const n = (t) => (e) => new m(e, t), i = {
486
468
  "km/h": {
487
469
  name: "Kilometer per hour",
488
470
  convertValue: 0.277778
489
- // Conversion factor from m/s to km/h
490
471
  },
491
472
  "ft/s": {
492
473
  name: "Foot per second",
493
474
  convertValue: 0.3048
494
- // Conversion factor from m/s to ft/s
495
475
  },
496
476
  "mi/h": {
497
477
  name: "Mile per hour",
498
478
  convertValue: 0.44704
499
- // Conversion factor from m/s to mi/h
500
479
  },
501
480
  knot: {
502
481
  name: "Knot",
503
482
  convertValue: 0.514444
504
- // Conversion factor from m/s to knots
505
483
  },
506
484
  "m/h": {
507
485
  name: "Meter per hour",
508
486
  convertValue: 1 / 3600
509
- // Conversion factor from m/s to m/h
510
487
  },
511
488
  "ft/h": {
512
489
  name: "Foot per hour",
513
- convertValue: 0.3048 / 3600
514
- // Conversion factor from m/s to ft/h
490
+ convertValue: 1 / 11811
515
491
  }
516
492
  }
517
493
  }, x = n(S), P = {
@@ -523,7 +499,7 @@ const n = (t) => (e) => new m(e, t), i = {
523
499
  },
524
500
  SCFD: {
525
501
  name: "Standard Cubic Feet per Day",
526
- convertValue: 211888e-8
502
+ convertValue: 1 / 35.3147
527
503
  // Conversion factor from SCMD to SCFD
528
504
  },
529
505
  MSCMD: {
@@ -538,12 +514,12 @@ const n = (t) => (e) => new m(e, t), i = {
538
514
  },
539
515
  MSCFD: {
540
516
  name: "Million Standard Cubic Feet per Day",
541
- convertValue: 211888e-8 * 1e3
517
+ convertValue: 1 / 35.3147 * 1e3
542
518
  // Conversion factor from SCMD to MSCFD
543
519
  },
544
520
  MMSCFD: {
545
521
  name: "Million Million Standard Cubic Feet per Day",
546
- convertValue: 211888e-8 * 1e6
522
+ convertValue: 1 / 35.3147 * 1e6
547
523
  // Conversion factor from SCMD to MMSCFD
548
524
  }
549
525
  }
@@ -557,17 +533,14 @@ const n = (t) => (e) => new m(e, t), i = {
557
533
  "dyn/cm": {
558
534
  name: "Dyne per Centimeter",
559
535
  convertValue: 1e-3
560
- // Conversion factor from N/m to dyn/cm
561
536
  },
562
537
  "lbf/ft": {
563
538
  name: "Pound-force per Foot",
564
- convertValue: 0.3048
565
- // Conversion factor from N/m to lbf/ft
539
+ convertValue: 1.35582
566
540
  },
567
541
  "mN/m": {
568
542
  name: "Millinewton per Meter",
569
543
  convertValue: 1e-3
570
- // Conversion factor from N/m to mN/m
571
544
  }
572
545
  }
573
546
  }, Q = n(k), w = {
@@ -602,28 +575,23 @@ const n = (t) => (e) => new m(e, t), i = {
602
575
  },
603
576
  "Pa·s": {
604
577
  name: "Pascal second",
605
- convertValue: 1e-3
606
- // Conversion factor from cP to Pa·s
578
+ convertValue: 1 / 1e-3
607
579
  },
608
- "lb·ft/s·h": {
609
- name: "Pound-foot per second-hour",
610
- convertValue: 241909e-12
611
- // Conversion factor from cP to lb·ft/s·h
580
+ "lb/ft·s": {
581
+ name: "Pound per second-foot",
582
+ convertValue: 1 / 671968994813e-15
612
583
  },
613
- "kg/m·s·h": {
584
+ "kg/m·s": {
614
585
  name: "Kilogram per meter-second-hour",
615
- convertValue: 1e-3 / 3600
616
- // Conversion factor from cP to kg/m·s·h
586
+ convertValue: 1 / 1e-3
617
587
  },
618
- "lb·ft/s·ft": {
619
- name: "Pound-foot per second-foot",
620
- convertValue: 241909e-12 / 3600
621
- // Conversion factor from cP to lb·ft/s·ft
588
+ "lb/ft·h": {
589
+ name: "Pound per hour-foot",
590
+ convertValue: 1 / 2.4190883105
622
591
  },
623
- "kg/m·s·m": {
592
+ "kg/m·h": {
624
593
  name: "Kilogram per meter-second-meter",
625
- convertValue: 1e-3 / 3600 / 3600
626
- // Conversion factor from cP to kg/m·s·m
594
+ convertValue: 1 / 3.6
627
595
  }
628
596
  }
629
597
  }, R = n(_), $ = {
@@ -643,40 +611,35 @@ const n = (t) => (e) => new m(e, t), i = {
643
611
  convertValue: 1e3
644
612
  }
645
613
  }
646
- }, X = n($), K = {
647
- baseUnit: "",
614
+ }, X = n($), q = {
615
+ baseUnit: "m3",
648
616
  units: {
649
- "m³": {
617
+ m3: {
650
618
  name: "Cubic Meter",
651
619
  convertValue: 1
652
620
  },
653
621
  liter: {
654
622
  name: "Liter",
655
623
  convertValue: 1e-3
656
- // Conversion factor from m³ to liters
657
624
  },
658
- "cm³": {
625
+ cm3: {
659
626
  name: "Cubic Centimeter",
660
627
  convertValue: 1e-6
661
- // Conversion factor from m³ to cm³
662
628
  },
663
- "mm³": {
629
+ mm3: {
664
630
  name: "Cubic Millimeter",
665
631
  convertValue: 1e-9
666
- // Conversion factor from m³ to mm³
667
632
  },
668
633
  gallon: {
669
634
  name: "Gallon",
670
- convertValue: 378541e-8
671
- // Conversion factor from m³ to gallons
635
+ convertValue: 454609e-8
672
636
  },
673
637
  quart: {
674
638
  name: "Quart",
675
- convertValue: 946353e-9
676
- // Conversion factor from m³ to quarts
639
+ convertValue: 1 / 879.877
677
640
  }
678
641
  }
679
- }, Z = n(K), F = {
642
+ }, Z = n(q), K = {
680
643
  baseUnit: "m3/h",
681
644
  units: {
682
645
  "m3/h": {
@@ -686,51 +649,43 @@ const n = (t) => (e) => new m(e, t), i = {
686
649
  "m3/day": {
687
650
  name: "Cubic meter per day",
688
651
  convertValue: 1 / 24
689
- // Assuming 1 day = 24 hours
690
652
  },
691
653
  "ft3/h": {
692
654
  name: "Cubic foot per hour",
693
655
  convertValue: 0.0283168
694
- // Conversion factor from cubic meter to cubic foot
695
656
  },
696
657
  "ft3/day": {
697
658
  name: "Cubic foot per day",
698
659
  convertValue: 0.0283168 / 24
699
- // Conversion factor from cubic meter to cubic foot, assuming 1 day = 24 hours
700
660
  },
701
661
  "gal/h": {
702
662
  name: "Gallon per hour",
703
663
  convertValue: 378541e-8
704
- // Conversion factor from cubic meter to gallon
705
664
  },
706
665
  "gal/day": {
707
666
  name: "Gallon per day",
708
667
  convertValue: 378541e-8 / 24
709
- // Conversion factor from cubic meter to gallon, assuming 1 day = 24 hours
710
668
  },
711
669
  "m3/s": {
712
670
  name: "Cubic meter per second",
713
- convertValue: 1 / 3600
714
- // Assuming 1 hour = 3600 seconds
671
+ convertValue: 3600
715
672
  },
716
673
  "ft3/s": {
717
674
  name: "Cubic foot per second",
718
- convertValue: 0.0283168 / 3600
719
- // Conversion factor from cubic meter to cubic foot, assuming 1 hour = 3600 seconds
675
+ convertValue: 1 / 980963e-8
720
676
  },
721
677
  "gal/s": {
722
678
  name: "Gallon per second",
723
- convertValue: 378541e-8 / 3600
724
- // Conversion factor from cubic meter to gallon, assuming 1 hour = 3600 seconds
679
+ convertValue: 378541e-8 * 3600
725
680
  }
726
681
  }
727
- }, ee = n(F);
682
+ }, ee = n(K);
728
683
  export {
729
684
  A as acceleration,
730
- T as area,
731
- N as density,
732
- G as electricCharge,
733
- I as electricCurrent,
685
+ N as area,
686
+ G as density,
687
+ I as electricCharge,
688
+ T as electricCurrent,
734
689
  W as energy,
735
690
  B as force,
736
691
  J as length,
@@ -741,8 +696,8 @@ export {
741
696
  z as pressureManometric,
742
697
  x as speed,
743
698
  L as standardVolumetricFlow,
744
- Q as surfaceTension,
745
699
  Y as time,
700
+ Q as torque,
746
701
  R as viscosity,
747
702
  X as voltage,
748
703
  Z 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 W=Object.defineProperty;var B=(e,t,o)=>t in e?W(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var c=(e,t,o)=>(B(e,typeof t!="symbol"?t+"":t,o),o);class t{constructor(n,r){c(this,"_definitions");c(this,"_val");c(this,"_fromUnit",null);this._definitions=r,this._val=n}from(n){return this._checkUnit(n),this._fromUnit=n,this}to(n){if(!this._fromUnit)throw new Error('Please specify the "from" unit using the from() method before calling to().');this._checkUnit(n);const r=this._getUnit(n),I=this._getUnit(this._fromUnit);return this._val*I/r}_getUnit(n){return this._definitions.units[n].convertValue}_checkUnit(n){const r=Object.keys(this._definitions.units);if(!r.includes(n))throw new Error(`Invalid unit "${n}". Available units: ${r.join(", ")}`)}}class o{constructor(n,r){c(this,"_internalConverter");this._internalConverter=new t(n,r)}from(n){return this._internalConverter.from(n),new u(this._internalConverter)}}class u{constructor(n){this._internalConverter=n}to(n){return this._internalConverter.to(n)}}const a=l=>n=>new o(n,l),m=a({baseUnit:"m/",units:{"m/":{name:"Meter per Second Squared",convertValue:1},"km/":{name:"Kilometer per Second Squared",convertValue:1e6},"cm/":{name:"Centimeter per Second Squared",convertValue:1e-4},g:{name:"Gravity",convertValue:9.80665},"ft/":{name:"Foot per Second Squared",convertValue:.3048}}}),i={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.7639},sqyd:{name:"Square Yard",convertValue:1/1.19599},acre:{name:"Acre",convertValue:1/247105e-9},hectare:{name:"Hectare",convertValue:1/1e-4}}},s=a(i),v={baseUnit:"kg/m3",units:{"kg/m3":{name:"Kilogram per cubic meter",convertValue:1},"lb/ft3":{name:"Pound per cubic foot",convertValue:.0160185},"g/cm3":{name:"Gram per cubic centimeter",convertValue:.001},"kg/ft3":{name:"Kilogram per cubic foot",convertValue:1/16.0185},"lb/m3":{name:"Pound per cubic meter",convertValue:.0160185/1e3}}},V=a(v),d=a({baseUnit:"C",units:{C:{name:"Coulomb",convertValue:1},mC:{name:"MilliCoulomb",convertValue:.001},μC:{name:"MicroCoulomb",convertValue:1e-6},nC:{name:"NanoCoulomb",convertValue:1e-9},pC:{name:"PicoCoulomb",convertValue:1e-12}}}),h=a({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}}}),p={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}}},b=a(p),g=a({baseUnit:"N",units:{N:{name:"Newton",convertValue:1},dyn:{name:"Dyne",convertValue:1e-5},lbf:{name:"Pound-force",convertValue:4.44822},kgf:{name:"Kilogram-force",convertValue:9.80665}}}),f=a({baseUnit:"m",units:{mm:{name:"Millimeter",convertValue:.001},cm:{name:"Centimeter",convertValue:.01},m:{name:"Meter",convertValue:1},in:{name:"Inch",convertValue:.0254},ft:{name:"Foot",convertValue:.3048}}}),C={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:453592e-9*(1/86400)},"g/s":{name:"Gram per second",convertValue:.001},"lb/h":{name:"Pound per hour",convertValue:453592e-9},"ton/day":{name:"Ton per day",convertValue:1e3*(1/86400)},"oz/min":{name:"Ounce per minute",convertValue:.0283495/60},"ton/year":{name:"Ton per year",convertValue:1e3/86400/365},"lb/s":{name:"Pound per second",convertValue:453592e-9},"kg/day":{name:"Kilogram per day",convertValue:1/86400}}},M=a(C),y=a({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}}}),S=a({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:3.41214},"cal/s":{name:"Calorie per second",convertValue:239.006}}}),U=a({baseUnit:"Pa",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}}}),P=a({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}}}),k={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:.3048/3600}}},w=a(k),_={baseUnit:"SCMD",units:{SCMD:{name:"Standard Cubic Meters per Day",convertValue:1},SCFD:{name:"Standard Cubic Feet per Day",convertValue:.00211888},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:.00211888*1e3},MMSCFD:{name:"Million Million Standard Cubic Feet per Day",convertValue:.00211888*1e6}}},$=a(_),K=a({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:.3048},"mN/m":{name:"Millinewton per Meter",convertValue:.001}}}),F=a({baseUnit:"s",units:{s:{name:"Second",convertValue:1},min:{name:"Minute",convertValue:60},hr:{name:"Hour",convertValue:3600},day:{name:"Day",convertValue:86400}}}),q={baseUnit:"cP",units:{cP:{name:"Centipoise",convertValue:1},"Pa·s":{name:"Pascal second",convertValue:.001},"lb·ft/s·h":{name:"Pound-foot per second-hour",convertValue:241909e-12},"kg/m·s·h":{name:"Kilogram per meter-second-hour",convertValue:.001/3600},"lb·ft/s·ft":{name:"Pound-foot per second-foot",convertValue:241909e-12/3600},"kg/m·s·m":{name:"Kilogram per meter-second-meter",convertValue:.001/3600/3600}}},D=a(q),T=a({baseUnit:"V",units:{V:{name:"Volt",convertValue:1},mV:{name:"Millivolt",convertValue:.001},kV:{name:"Kilovolt",convertValue:1e3}}}),A=a({baseUnit:"",units:{"m³":{name:"Cubic Meter",convertValue:1},liter:{name:"Liter",convertValue:.001},"cm³":{name:"Cubic Centimeter",convertValue:1e-6},"mm³":{name:"Cubic Millimeter",convertValue:1e-9},gallon:{name:"Gallon",convertValue:.00378541},quart:{name:"Quart",convertValue:946353e-9}}}),N={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:1/3600},"ft3/s":{name:"Cubic foot per second",convertValue:.0283168/3600},"gal/s":{name:"Gallon per second",convertValue:.00378541/3600}}},G=a(N);e.acceleration=m,e.area=s,e.density=V,e.electricCharge=d,e.electricCurrent=h,e.energy=b,e.force=g,e.length=f,e.mass=y,e.massFlow=M,e.power=S,e.pressure=P,e.pressureManometric=U,e.speed=w,e.standardVolumetricFlow=$,e.surfaceTension=K,e.time=F,e.viscosity=D,e.voltage=T,e.volume=A,e.volumetricFlow=G,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 O=Object.defineProperty;var H=(e,t,o)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var c=(e,t,o)=>(H(e,typeof t!="symbol"?t+"":t,o),o);class t{constructor(n,r){c(this,"_definitions");c(this,"_val");c(this,"_fromUnit",null);this._definitions=r,this._val=n}from(n){return this._checkUnit(n),this._fromUnit=n,this}to(n){if(!this._fromUnit)throw new Error('Please specify the "from" unit using the from() method before calling to().');this._checkUnit(n);const r=this._getUnit(n),J=this._getUnit(this._fromUnit);return this._val*J/r}_getUnit(n){return this._definitions.units[n].convertValue}_checkUnit(n){const r=Object.keys(this._definitions.units);if(!r.includes(n))throw new Error(`Invalid unit "${n}". Available units: ${r.join(", ")}`)}}class o{constructor(n,r){c(this,"_internalConverter");this._internalConverter=new t(n,r)}from(n){return this._internalConverter.from(n),new u(this._internalConverter)}}class u{constructor(n){this._internalConverter=n}to(n){return this._internalConverter.to(n)}}const a=l=>n=>new o(n,l),m={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}}},i=a(m),s={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}}},v=a(s),V={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=a(V),h=a({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}}}),p=a({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}}},g=a(b),C={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}}},f=a(C),M=a({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}}}),y={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}}},S=a(y),U=a({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}}}),P={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}}},k=a(P),w=a({baseUnit:"Pa",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}}}),q=a({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}}}),_={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}}},$=a(_),K={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}}},F=a(K),D=a({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:1.35582},"mN/m":{name:"Millinewton per Meter",convertValue:.001}}}),A=a({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},"Pa·s":{name:"Pascal second",convertValue:1/.001},"lb/ft·s":{name:"Pound per second-foot",convertValue:1/.000671968994813},"kg/m·s":{name:"Kilogram per meter-second-hour",convertValue:1/.001},"lb/ft·h":{name:"Pound per hour-foot",convertValue:1/2.4190883105},"kg/m·h":{name:"Kilogram per meter-second-meter",convertValue:1/3.6}}},N=a(T),G=a({baseUnit:"V",units:{V:{name:"Volt",convertValue:1},mV:{name:"Millivolt",convertValue:.001},kV:{name:"Kilovolt",convertValue:1e3}}}),I={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}}},W=a(I),B={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}}},j=a(B);e.acceleration=i,e.area=v,e.density=d,e.electricCharge=h,e.electricCurrent=p,e.energy=g,e.force=f,e.length=M,e.mass=U,e.massFlow=S,e.power=k,e.pressure=q,e.pressureManometric=w,e.speed=$,e.standardVolumetricFlow=F,e.time=A,e.torque=D,e.viscosity=N,e.voltage=G,e.volume=W,e.volumetricFlow=j,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});
package/dist/index.d.ts CHANGED
@@ -13,7 +13,7 @@ export { default as pressureManometric } from './units/pressure-manometric';
13
13
  export { default as pressure } from './units/pressure';
14
14
  export { default as speed } from './units/speed';
15
15
  export { default as standardVolumetricFlow } from './units/standard-volumetric-flow';
16
- export { default as surfaceTension } from './units/surface-tension';
16
+ export { default as torque } from './units/torque';
17
17
  export { default as time } from './units/time';
18
18
  export { default as viscosity } from './units/viscosity';
19
19
  export { default as voltage } from './units/voltage';
package/dist/types.d.ts CHANGED
@@ -56,10 +56,10 @@ export type Density = {
56
56
  export type ViscosityUnits = {
57
57
  cP: UnitsValues;
58
58
  'Pa·s': UnitsValues;
59
- 'lb·ft/s·h': UnitsValues;
60
- 'kg/m·h': UnitsValues;
61
- 'lb·ft/s·ft': UnitsValues;
62
- 'kg/m·s·m': UnitsValues;
59
+ 'lb/ft·s': UnitsValues;
60
+ 'kg/m·h': UnitsValues;
61
+ 'lb/ft·h': UnitsValues;
62
+ 'kg/m·s': UnitsValues;
63
63
  };
64
64
  export type Viscosity = {
65
65
  baseUnit: 'cP';
@@ -140,15 +140,15 @@ export type Area = {
140
140
  units: AreaUnits;
141
141
  };
142
142
  export type VolumeUnits = {
143
- '': UnitsValues;
143
+ 'm3': UnitsValues;
144
144
  'liter': UnitsValues;
145
- 'cm³': UnitsValues;
146
- 'mm³': UnitsValues;
145
+ 'cm3': UnitsValues;
146
+ 'mm3': UnitsValues;
147
147
  'gallon': UnitsValues;
148
148
  'quart': UnitsValues;
149
149
  };
150
150
  export type Volume = {
151
- baseUnit: '';
151
+ baseUnit: 'm3';
152
152
  units: VolumeUnits;
153
153
  };
154
154
  export type ForceUnits = {
@@ -161,15 +161,15 @@ export type Force = {
161
161
  baseUnit: 'N';
162
162
  units: ForceUnits;
163
163
  };
164
- export type SurfaceTensionUnits = {
164
+ export type TorqueUnits = {
165
165
  'N/m': UnitsValues;
166
166
  'dyn/cm': UnitsValues;
167
167
  'lbf/ft': UnitsValues;
168
168
  'mN/m': UnitsValues;
169
169
  };
170
- export type SurfaceTension = {
170
+ export type Torque = {
171
171
  baseUnit: 'N/m';
172
- units: SurfaceTensionUnits;
172
+ units: TorqueUnits;
173
173
  };
174
174
  export type TimeUnits = {
175
175
  's': UnitsValues;
@@ -204,14 +204,13 @@ export type ElectricCurrent = {
204
204
  units: ElectricCurrentUnits;
205
205
  };
206
206
  export type AccelerationUnits = {
207
- 'm/': UnitsValues;
208
- 'km/': UnitsValues;
209
- 'cm/': UnitsValues;
210
- 'g': UnitsValues;
211
- 'ft/s²': UnitsValues;
207
+ 'm/s2': UnitsValues;
208
+ 'km/s2': UnitsValues;
209
+ 'cm/s2': UnitsValues;
210
+ 'ft/s2': UnitsValues;
212
211
  };
213
212
  export type Acceleration = {
214
- baseUnit: 'm/';
213
+ baseUnit: 'm/s2';
215
214
  units: AccelerationUnits;
216
215
  };
217
216
  export type PressureUnits = {
@@ -252,7 +251,7 @@ export type StandardVolumetricFlow = {
252
251
  baseUnit: 'SCMD';
253
252
  units: StandardVolumetricFlowUnits;
254
253
  };
255
- export type Measurement = Voltage | MassFlow | VolumetricFlow | Density | Viscosity | Length | Mass | Speed | Power | Energy | Area | Volume | Force | SurfaceTension | Time | ElectricCharge | ElectricCurrent | Acceleration | Pressure | PressureManometric | StandardVolumetricFlow;
254
+ export type Measurement = Voltage | MassFlow | VolumetricFlow | Density | Viscosity | Length | Mass | Speed | Power | Energy | Area | Volume | Force | Torque | Time | ElectricCharge | ElectricCurrent | Acceleration | Pressure | PressureManometric | StandardVolumetricFlow;
256
255
  export type MeasurementUnits<T extends Measurement> = T extends {
257
256
  units: infer U;
258
257
  } ? keyof U : never;
@@ -0,0 +1,9 @@
1
+ import { type Torque } from '../types';
2
+ declare const _default: (val: number) => {
3
+ readonly _internalConverter: import("../internalConverter").default<Torque>;
4
+ from<U extends keyof import("../types").TorqueUnits>(fromUnit: U): {
5
+ readonly _internalConverter: import("../internalConverter").default<Torque>;
6
+ to<U_1 extends keyof import("../types").TorqueUnits>(toUnit: U_1): number;
7
+ };
8
+ };
9
+ export default _default;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "type": "git",
5
5
  "url": "git+https://github.com/alanhaertel/engineering-unit-converter.git"
6
6
  },
7
- "version": "0.0.5",
7
+ "version": "0.0.7",
8
8
  "keywords": [
9
9
  "units",
10
10
  "engineering",
@@ -13,13 +13,14 @@
13
13
  "metric",
14
14
  "unit converter"
15
15
  ],
16
- "license": "mit",
16
+ "license": "MIT",
17
17
  "type": "module",
18
18
  "files": [
19
19
  "dist"
20
20
  ],
21
21
  "main": "./dist/engineering-unit-converter.umd.cjs",
22
22
  "module": "./dist/engineering-unit-converter.js",
23
+ "types": "./dist/index.d.ts",
23
24
  "exports": {
24
25
  ".": {
25
26
  "import": "./dist/engineering-unit-converter.js",
File without changes
@@ -1,9 +0,0 @@
1
- import { type SurfaceTension } from '../types';
2
- declare const _default: (val: number) => {
3
- readonly _internalConverter: import("../internalConverter").default<SurfaceTension>;
4
- from<U extends keyof import("../types").SurfaceTensionUnits>(fromUnit: U): {
5
- readonly _internalConverter: import("../internalConverter").default<SurfaceTension>;
6
- to<U_1 extends keyof import("../types").SurfaceTensionUnits>(toUnit: U_1): number;
7
- };
8
- };
9
- export default _default;