engineering-unit-converter 0.0.1

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.
@@ -0,0 +1,733 @@
1
+ var c = Object.defineProperty;
2
+ var l = (t, e, a) => e in t ? c(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a;
3
+ var r = (t, e, a) => (l(t, typeof e != "symbol" ? e + "" : e, a), a);
4
+ class u {
5
+ constructor(e, a) {
6
+ r(this, "_definitions");
7
+ r(this, "_val");
8
+ r(this, "_fromUnit", null);
9
+ this._definitions = a, this._val = e;
10
+ }
11
+ from(e) {
12
+ return this._checkUnit(e), this._fromUnit = e, this;
13
+ }
14
+ to(e) {
15
+ if (!this._fromUnit)
16
+ throw new Error('Please specify the "from" unit using the from() method before calling to().');
17
+ this._checkUnit(e);
18
+ const a = this._getUnit(e), o = this._getUnit(this._fromUnit);
19
+ return this._val * o / a;
20
+ }
21
+ _getUnit(e) {
22
+ return this._definitions.units[e].convertValue;
23
+ }
24
+ _checkUnit(e) {
25
+ const a = Object.keys(this._definitions.units);
26
+ if (!a.includes(e))
27
+ throw new Error(`Invalid unit "${e}". Available units: ${a.join(", ")}`);
28
+ }
29
+ }
30
+ const n = (t) => (e) => new u(e, t), m = {
31
+ baseUnit: "m/s²",
32
+ units: {
33
+ "m/s²": {
34
+ name: "Meter per Second Squared",
35
+ convertValue: 1
36
+ },
37
+ "km/s²": {
38
+ name: "Kilometer per Second Squared",
39
+ convertValue: 1e6
40
+ // Conversion factor from m/s² to km/s²
41
+ },
42
+ "cm/s²": {
43
+ name: "Centimeter per Second Squared",
44
+ convertValue: 1e-4
45
+ // Conversion factor from m/s² to cm/s²
46
+ },
47
+ g: {
48
+ name: "Gravity",
49
+ convertValue: 9.80665
50
+ // Standard gravity on Earth, in m/s²
51
+ },
52
+ "ft/s²": {
53
+ name: "Foot per Second Squared",
54
+ convertValue: 0.3048
55
+ // Conversion factor from m/s² to ft/s²
56
+ }
57
+ }
58
+ }, _ = n(m), s = {
59
+ baseUnit: "m2",
60
+ units: {
61
+ m2: {
62
+ name: "Square Meter",
63
+ convertValue: 1
64
+ },
65
+ km2: {
66
+ name: "Square Kilometer",
67
+ convertValue: 1 / 1e-6
68
+ // Conversion factor from m2 to km2
69
+ },
70
+ cm2: {
71
+ name: "Square Centimeter",
72
+ convertValue: 1 / 1e4
73
+ // Conversion factor from m2 to cm2
74
+ },
75
+ mm2: {
76
+ name: "Square Millimeter",
77
+ convertValue: 1 / 1e6
78
+ // Conversion factor from m2 to mm2
79
+ },
80
+ sqin: {
81
+ name: "Square Inch",
82
+ convertValue: 1 / 1550.0031
83
+ // Conversion factor from m2 to sqin
84
+ },
85
+ sqft: {
86
+ name: "Square Foot",
87
+ convertValue: 1 / 10.7639
88
+ // Conversion factor from m2 to sqft
89
+ },
90
+ sqyd: {
91
+ name: "Square Yard",
92
+ convertValue: 1 / 1.19599
93
+ // Conversion factor from m2 to sqyd
94
+ },
95
+ acre: {
96
+ name: "Acre",
97
+ convertValue: 1 / 247105e-9
98
+ // Conversion factor from m2 to acre
99
+ },
100
+ hectare: {
101
+ name: "Hectare",
102
+ convertValue: 1 / 1e-4
103
+ // Conversion factor from m2 to hectare
104
+ }
105
+ }
106
+ }, D = n(s), i = {
107
+ baseUnit: "kg/m3",
108
+ units: {
109
+ "kg/m3": {
110
+ name: "Kilogram per cubic meter",
111
+ convertValue: 1
112
+ },
113
+ "lb/ft3": {
114
+ name: "Pound per cubic foot",
115
+ convertValue: 0.0160185
116
+ // Conversion factor from kg/m3 to lb/ft3
117
+ },
118
+ "g/cm3": {
119
+ name: "Gram per cubic centimeter",
120
+ convertValue: 1e-3
121
+ // Conversion factor from kg/m3 to g/cm3
122
+ },
123
+ "kg/ft3": {
124
+ name: "Kilogram per cubic foot",
125
+ convertValue: 1 / 16.0185
126
+ // Conversion factor from lb/ft3 to kg/ft3
127
+ },
128
+ "lb/m3": {
129
+ name: "Pound per cubic meter",
130
+ convertValue: 0.0160185 / 1e3
131
+ // Conversion factor from lb/ft³ to lb/m³
132
+ }
133
+ }
134
+ }, A = n(i), v = {
135
+ baseUnit: "C",
136
+ units: {
137
+ C: {
138
+ name: "Coulomb",
139
+ convertValue: 1
140
+ },
141
+ mC: {
142
+ name: "MilliCoulomb",
143
+ convertValue: 1e-3
144
+ // Conversion factor from C to mC
145
+ },
146
+ μC: {
147
+ name: "MicroCoulomb",
148
+ convertValue: 1e-6
149
+ // Conversion factor from C to μC
150
+ },
151
+ nC: {
152
+ name: "NanoCoulomb",
153
+ convertValue: 1e-9
154
+ // Conversion factor from C to nC
155
+ },
156
+ pC: {
157
+ name: "PicoCoulomb",
158
+ convertValue: 1e-12
159
+ // Conversion factor from C to pC
160
+ }
161
+ }
162
+ }, T = n(v), V = {
163
+ baseUnit: "A",
164
+ units: {
165
+ A: {
166
+ name: "Ampere",
167
+ convertValue: 1
168
+ },
169
+ mA: {
170
+ name: "Milliampere",
171
+ convertValue: 1e-3
172
+ // Conversion factor from A to mA
173
+ },
174
+ μA: {
175
+ name: "Microampere",
176
+ convertValue: 1e-6
177
+ // Conversion factor from A to μA
178
+ },
179
+ nA: {
180
+ name: "Nanoampere",
181
+ convertValue: 1e-9
182
+ // Conversion factor from A to nA
183
+ },
184
+ pA: {
185
+ name: "Picoampere",
186
+ convertValue: 1e-12
187
+ // Conversion factor from A to pA
188
+ }
189
+ }
190
+ }, N = n(V), p = {
191
+ baseUnit: "J",
192
+ units: {
193
+ J: {
194
+ name: "Joule",
195
+ convertValue: 1
196
+ },
197
+ kJ: {
198
+ name: "Kilojoule",
199
+ convertValue: 1 / 1e-3
200
+ // Conversion factor from J to kJ
201
+ },
202
+ cal: {
203
+ name: "Calorie",
204
+ convertValue: 1 / 0.239006
205
+ // Conversion factor from J to cal
206
+ },
207
+ kcal: {
208
+ name: "Kilocalorie",
209
+ convertValue: 1 / 239006e-9
210
+ // Conversion factor from J to kcal
211
+ },
212
+ Wh: {
213
+ name: "Watt-hour",
214
+ convertValue: 1 / 277778e-9
215
+ // Conversion factor from J to Wh
216
+ },
217
+ kWh: {
218
+ name: "Kilowatt-hour",
219
+ convertValue: 1 / 277778e-12
220
+ // Conversion factor from J to kWh
221
+ },
222
+ BTU: {
223
+ name: "British Thermal Unit",
224
+ convertValue: 1 / 947817e-9
225
+ // Conversion factor from J to BTU
226
+ }
227
+ }
228
+ }, G = n(p), d = {
229
+ baseUnit: "N",
230
+ units: {
231
+ N: {
232
+ name: "Newton",
233
+ convertValue: 1
234
+ },
235
+ dyn: {
236
+ name: "Dyne",
237
+ convertValue: 1e-5
238
+ // Conversion factor from N to dyn
239
+ },
240
+ lbf: {
241
+ name: "Pound-force",
242
+ convertValue: 4.44822
243
+ // Conversion factor from N to lbf
244
+ },
245
+ kgf: {
246
+ name: "Kilogram-force",
247
+ convertValue: 9.80665
248
+ // Conversion factor from N to kgf
249
+ }
250
+ }
251
+ }, W = n(d), h = {
252
+ baseUnit: "m",
253
+ units: {
254
+ mm: {
255
+ name: "Millimeter",
256
+ convertValue: 1e-3
257
+ // Conversion factor from m to mm
258
+ },
259
+ cm: {
260
+ name: "Centimeter",
261
+ convertValue: 0.01
262
+ // Conversion factor from m to cm
263
+ },
264
+ m: {
265
+ name: "Meter",
266
+ convertValue: 1
267
+ },
268
+ in: {
269
+ name: "Inch",
270
+ convertValue: 0.0254
271
+ // Conversion factor from m to inch
272
+ },
273
+ ft: {
274
+ name: "Foot",
275
+ convertValue: 0.3048
276
+ // Conversion factor from m to ft
277
+ }
278
+ }
279
+ }, B = n(h), b = {
280
+ baseUnit: "kg/s",
281
+ units: {
282
+ "kg/s": {
283
+ name: "Kilogram per second",
284
+ convertValue: 1
285
+ },
286
+ "kg/h": {
287
+ name: "Kilogram per hour",
288
+ convertValue: 1 / 3600
289
+ // 1 hour = 3600 seconds
290
+ },
291
+ "lb/day": {
292
+ name: "Pound per day",
293
+ convertValue: 453592e-9 * (1 / 86400)
294
+ // 1 lb = 0.000453592 kg, 1 day = 86400 seconds
295
+ },
296
+ "g/s": {
297
+ name: "Gram per second",
298
+ convertValue: 1e-3
299
+ },
300
+ "lb/h": {
301
+ name: "Pound per hour",
302
+ convertValue: 453592e-9
303
+ },
304
+ "ton/day": {
305
+ name: "Ton per day",
306
+ convertValue: 1e3 * (1 / 86400)
307
+ // 1 ton = 1000 kg
308
+ },
309
+ "oz/min": {
310
+ name: "Ounce per minute",
311
+ convertValue: 0.0283495 / 60
312
+ // 1 oz = 0.0283495 kg, 1 minute = 60 seconds
313
+ },
314
+ "ton/year": {
315
+ name: "Ton per year",
316
+ // Adjust the name as needed
317
+ convertValue: 1e3 / 86400 / 365
318
+ // Assuming 1 ton/year = 1000 kg / 86400 seconds / 365 days
319
+ },
320
+ "lb/s": {
321
+ name: "Pound per second",
322
+ convertValue: 453592e-9
323
+ },
324
+ "kg/day": {
325
+ name: "Kilogram per day",
326
+ convertValue: 1 / 86400
327
+ // 1 day = 86400 seconds
328
+ }
329
+ }
330
+ }, I = n(b), g = {
331
+ baseUnit: "kg",
332
+ units: {
333
+ kg: {
334
+ name: "Kilogram",
335
+ convertValue: 1
336
+ },
337
+ g: {
338
+ name: "Gram",
339
+ convertValue: 1e-3
340
+ // Conversion factor from kg to g
341
+ },
342
+ lb: {
343
+ name: "Pound",
344
+ convertValue: 0.453592
345
+ // Conversion factor from kg to lb
346
+ },
347
+ oz: {
348
+ name: "Ounce",
349
+ convertValue: 0.0283495
350
+ // Conversion factor from kg to oz
351
+ },
352
+ ton: {
353
+ name: "Ton",
354
+ convertValue: 1e3
355
+ // Conversion factor from kg to ton
356
+ }
357
+ }
358
+ }, J = n(g), C = {
359
+ baseUnit: "W",
360
+ units: {
361
+ W: {
362
+ name: "Watt",
363
+ convertValue: 1
364
+ },
365
+ kW: {
366
+ name: "Kilowatt",
367
+ convertValue: 1e3
368
+ // Conversion factor from W to kW
369
+ },
370
+ hp: {
371
+ name: "Horsepower",
372
+ convertValue: 745.7
373
+ // Conversion factor from W to hp
374
+ },
375
+ "BTU/h": {
376
+ name: "British Thermal Unit per hour",
377
+ convertValue: 3.41214
378
+ // Conversion factor from W to BTU/h
379
+ },
380
+ "cal/s": {
381
+ name: "Calorie per second",
382
+ convertValue: 239.006
383
+ // Conversion factor from W to cal/s
384
+ }
385
+ }
386
+ }, j = n(C), f = {
387
+ baseUnit: "Pa",
388
+ units: {
389
+ Pag: {
390
+ name: "Pascal",
391
+ convertValue: 1
392
+ },
393
+ kPag: {
394
+ name: "Kilopascal",
395
+ convertValue: 1e3
396
+ // Conversion factor from Pa to kPa
397
+ },
398
+ MPag: {
399
+ name: "Megapascal",
400
+ convertValue: 1e6
401
+ // Conversion factor from Pa to MPa
402
+ },
403
+ barg: {
404
+ name: "Bar",
405
+ convertValue: 1e5
406
+ // Conversion factor from Pa to Bar
407
+ },
408
+ atmg: {
409
+ name: "Atmosphere",
410
+ convertValue: 101325
411
+ // Standard atmospheric pressure in Pa
412
+ },
413
+ psig: {
414
+ name: "Pound per Square Inch",
415
+ convertValue: 6894.76
416
+ // Conversion factor from Pa to psi
417
+ },
418
+ "kg/cm2g": {
419
+ name: "Kilogram per Square Centimeter",
420
+ convertValue: 98066.5
421
+ // Conversion factor from Pa to kg/cm²
422
+ }
423
+ }
424
+ }, H = n(f), M = {
425
+ baseUnit: "Pa",
426
+ units: {
427
+ Pa: {
428
+ name: "Pascal",
429
+ convertValue: 1
430
+ },
431
+ kPa: {
432
+ name: "Kilopascal",
433
+ convertValue: 1e3
434
+ // Conversion factor from Pa to kPa
435
+ },
436
+ MPa: {
437
+ name: "Megapascal",
438
+ convertValue: 1e6
439
+ // Conversion factor from Pa to MPa
440
+ },
441
+ bar: {
442
+ name: "Bar",
443
+ convertValue: 1e5
444
+ // Conversion factor from Pa to Bar
445
+ },
446
+ atm: {
447
+ name: "Atmosphere",
448
+ convertValue: 101325
449
+ // Standard atmospheric pressure in Pa
450
+ },
451
+ psi: {
452
+ name: "Pound per Square Inch",
453
+ convertValue: 6894.76
454
+ // Conversion factor from Pa to psi
455
+ },
456
+ "kg/cm2": {
457
+ name: "Kilogram per Square Centimeter",
458
+ convertValue: 98066.5
459
+ // Conversion factor from Pa to kg/cm²
460
+ }
461
+ }
462
+ }, O = n(M), y = {
463
+ baseUnit: "m/s",
464
+ units: {
465
+ "m/s": {
466
+ name: "Meter per second",
467
+ convertValue: 1
468
+ },
469
+ "km/h": {
470
+ name: "Kilometer per hour",
471
+ convertValue: 0.277778
472
+ // Conversion factor from m/s to km/h
473
+ },
474
+ "ft/s": {
475
+ name: "Foot per second",
476
+ convertValue: 0.3048
477
+ // Conversion factor from m/s to ft/s
478
+ },
479
+ "mi/h": {
480
+ name: "Mile per hour",
481
+ convertValue: 0.44704
482
+ // Conversion factor from m/s to mi/h
483
+ },
484
+ knot: {
485
+ name: "Knot",
486
+ convertValue: 0.514444
487
+ // Conversion factor from m/s to knots
488
+ },
489
+ "m/h": {
490
+ name: "Meter per hour",
491
+ convertValue: 1 / 3600
492
+ // Conversion factor from m/s to m/h
493
+ },
494
+ "ft/h": {
495
+ name: "Foot per hour",
496
+ convertValue: 0.3048 / 3600
497
+ // Conversion factor from m/s to ft/h
498
+ }
499
+ }
500
+ }, z = n(y), U = {
501
+ baseUnit: "SCMD",
502
+ units: {
503
+ SCMD: {
504
+ name: "Standard Cubic Meters per Day",
505
+ convertValue: 1
506
+ },
507
+ SCFD: {
508
+ name: "Standard Cubic Feet per Day",
509
+ convertValue: 211888e-8
510
+ // Conversion factor from SCMD to SCFD
511
+ },
512
+ MSCMD: {
513
+ name: "Million Standard Cubic Meters per Day",
514
+ convertValue: 1e3
515
+ // Conversion factor from SCMD to MSCMD
516
+ },
517
+ MMSCMD: {
518
+ name: "Million Million Standard Cubic Meters per Day",
519
+ convertValue: 1e6
520
+ // Conversion factor from SCMD to MMSCMD
521
+ },
522
+ MSCFD: {
523
+ name: "Million Standard Cubic Feet per Day",
524
+ convertValue: 211888e-8 * 1e3
525
+ // Conversion factor from SCMD to MSCFD
526
+ },
527
+ MMSCFD: {
528
+ name: "Million Million Standard Cubic Feet per Day",
529
+ convertValue: 211888e-8 * 1e6
530
+ // Conversion factor from SCMD to MMSCFD
531
+ }
532
+ }
533
+ }, E = n(U), S = {
534
+ baseUnit: "N/m",
535
+ units: {
536
+ "N/m": {
537
+ name: "Newton per Meter",
538
+ convertValue: 1
539
+ },
540
+ "dyn/cm": {
541
+ name: "Dyne per Centimeter",
542
+ convertValue: 1e-3
543
+ // Conversion factor from N/m to dyn/cm
544
+ },
545
+ "lbf/ft": {
546
+ name: "Pound-force per Foot",
547
+ convertValue: 0.3048
548
+ // Conversion factor from N/m to lbf/ft
549
+ },
550
+ "mN/m": {
551
+ name: "Millinewton per Meter",
552
+ convertValue: 1e-3
553
+ // Conversion factor from N/m to mN/m
554
+ }
555
+ }
556
+ }, x = n(S), k = {
557
+ baseUnit: "s",
558
+ units: {
559
+ s: {
560
+ name: "Second",
561
+ convertValue: 1
562
+ },
563
+ min: {
564
+ name: "Minute",
565
+ convertValue: 60
566
+ // Conversion factor from seconds to minutes
567
+ },
568
+ hr: {
569
+ name: "Hour",
570
+ convertValue: 3600
571
+ // Conversion factor from seconds to hours
572
+ },
573
+ day: {
574
+ name: "Day",
575
+ convertValue: 86400
576
+ // Conversion factor from seconds to days
577
+ }
578
+ }
579
+ }, L = n(k), P = {
580
+ baseUnit: "cP",
581
+ units: {
582
+ cP: {
583
+ name: "Centipoise",
584
+ convertValue: 1
585
+ },
586
+ "Pa·s": {
587
+ name: "Pascal second",
588
+ convertValue: 1e-3
589
+ // Conversion factor from cP to Pa·s
590
+ },
591
+ "lb·ft/s·h": {
592
+ name: "Pound-foot per second-hour",
593
+ convertValue: 241909e-12
594
+ // Conversion factor from cP to lb·ft/s·h
595
+ },
596
+ "kg/m·s·h": {
597
+ name: "Kilogram per meter-second-hour",
598
+ convertValue: 1e-3 / 3600
599
+ // Conversion factor from cP to kg/m·s·h
600
+ },
601
+ "lb·ft/s·ft": {
602
+ name: "Pound-foot per second-foot",
603
+ convertValue: 241909e-12 / 3600
604
+ // Conversion factor from cP to lb·ft/s·ft
605
+ },
606
+ "kg/m·s·m": {
607
+ name: "Kilogram per meter-second-meter",
608
+ convertValue: 1e-3 / 3600 / 3600
609
+ // Conversion factor from cP to kg/m·s·m
610
+ }
611
+ }
612
+ }, Q = n(P), w = {
613
+ baseUnit: "V",
614
+ // transform: (val) => val * baseValue,
615
+ units: {
616
+ V: {
617
+ name: "Volt",
618
+ convertValue: 1
619
+ },
620
+ mV: {
621
+ name: "Millivolt",
622
+ convertValue: 1e-3
623
+ },
624
+ kV: {
625
+ name: "Kilovolt",
626
+ convertValue: 1e3
627
+ }
628
+ }
629
+ }, Y = n(w), $ = {
630
+ baseUnit: "m³",
631
+ units: {
632
+ "m³": {
633
+ name: "Cubic Meter",
634
+ convertValue: 1
635
+ },
636
+ liter: {
637
+ name: "Liter",
638
+ convertValue: 1e-3
639
+ // Conversion factor from m³ to liters
640
+ },
641
+ "cm³": {
642
+ name: "Cubic Centimeter",
643
+ convertValue: 1e-6
644
+ // Conversion factor from m³ to cm³
645
+ },
646
+ "mm³": {
647
+ name: "Cubic Millimeter",
648
+ convertValue: 1e-9
649
+ // Conversion factor from m³ to mm³
650
+ },
651
+ gallon: {
652
+ name: "Gallon",
653
+ convertValue: 378541e-8
654
+ // Conversion factor from m³ to gallons
655
+ },
656
+ quart: {
657
+ name: "Quart",
658
+ convertValue: 946353e-9
659
+ // Conversion factor from m³ to quarts
660
+ }
661
+ }
662
+ }, R = n($), K = {
663
+ baseUnit: "m3/h",
664
+ units: {
665
+ "m3/h": {
666
+ name: "Cubic meter per hour",
667
+ convertValue: 1
668
+ },
669
+ "m3/day": {
670
+ name: "Cubic meter per day",
671
+ convertValue: 1 / 24
672
+ // Assuming 1 day = 24 hours
673
+ },
674
+ "ft3/h": {
675
+ name: "Cubic foot per hour",
676
+ convertValue: 0.0283168
677
+ // Conversion factor from cubic meter to cubic foot
678
+ },
679
+ "ft3/day": {
680
+ name: "Cubic foot per day",
681
+ convertValue: 0.0283168 / 24
682
+ // Conversion factor from cubic meter to cubic foot, assuming 1 day = 24 hours
683
+ },
684
+ "gal/h": {
685
+ name: "Gallon per hour",
686
+ convertValue: 378541e-8
687
+ // Conversion factor from cubic meter to gallon
688
+ },
689
+ "gal/day": {
690
+ name: "Gallon per day",
691
+ convertValue: 378541e-8 / 24
692
+ // Conversion factor from cubic meter to gallon, assuming 1 day = 24 hours
693
+ },
694
+ "m3/s": {
695
+ name: "Cubic meter per second",
696
+ convertValue: 1 / 3600
697
+ // Assuming 1 hour = 3600 seconds
698
+ },
699
+ "ft3/s": {
700
+ name: "Cubic foot per second",
701
+ convertValue: 0.0283168 / 3600
702
+ // Conversion factor from cubic meter to cubic foot, assuming 1 hour = 3600 seconds
703
+ },
704
+ "gal/s": {
705
+ name: "Gallon per second",
706
+ convertValue: 378541e-8 / 3600
707
+ // Conversion factor from cubic meter to gallon, assuming 1 hour = 3600 seconds
708
+ }
709
+ }
710
+ }, X = n(K);
711
+ export {
712
+ _ as acceleration,
713
+ D as area,
714
+ A as density,
715
+ T as electricCharge,
716
+ N as electricCurrent,
717
+ G as energy,
718
+ W as force,
719
+ B as length,
720
+ J as mass,
721
+ I as massFlow,
722
+ j as power,
723
+ O as pressure,
724
+ H as pressureManometric,
725
+ z as speed,
726
+ E as standardVolumetricFlow,
727
+ x as surfaceTension,
728
+ L as time,
729
+ Q as viscosity,
730
+ Y as voltage,
731
+ R as volume,
732
+ X as volumetricFlow
733
+ };