engineering-unit-converter 0.0.14 → 0.0.16
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 +50 -49
- package/dist/engineering-unit-converter.js +155 -100
- package/dist/engineering-unit-converter.umd.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/types.d.ts +17 -1
- package/dist/units/mass-per-standard-volume.d.ts +9 -0
- package/package.json +7 -4
package/README.md
CHANGED
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
engineering-unit-converter
|
|
2
|
-
=============
|
|
3
|
-
|
|
4
|
-
A light and simple library for make all type measures conversions and manipulations.
|
|
5
|
-
Used [convert-units](https://github.com/ben-ng/convert-units) as a reference.
|
|
6
|
-
|
|
7
|
-
Installation
|
|
8
|
-
-----
|
|
9
|
-
|
|
10
|
-
```bash
|
|
11
|
-
npm install engineering-unit-converter
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
Usage
|
|
15
|
-
-----
|
|
16
|
-
|
|
17
|
-
`engineering-unit-converter` uses TypeScript to infer the available units, I strongly recommend using it for making the dev experience better.
|
|
18
|
-
|
|
19
|
-
Using this library is simple, the above snippet shows an example:
|
|
20
|
-
|
|
21
|
-
```js
|
|
22
|
-
import { massFlow } from 'engineering-unit-converter'
|
|
23
|
-
const newValue = massFlow(65000).from('lb/day').to('kg/h')
|
|
24
|
-
console.log(newValue) //1228.4818798922718
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
Available units
|
|
28
|
-
-----
|
|
29
|
-
|
|
30
|
-
- acceleration
|
|
31
|
-
- area
|
|
32
|
-
- density
|
|
33
|
-
- electricCharge
|
|
34
|
-
- electricCurrent
|
|
35
|
-
- energy
|
|
36
|
-
- force
|
|
37
|
-
- length
|
|
38
|
-
- massFlow
|
|
39
|
-
- mass
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
43
|
-
-
|
|
44
|
-
-
|
|
45
|
-
-
|
|
46
|
-
-
|
|
47
|
-
-
|
|
48
|
-
-
|
|
49
|
-
-
|
|
1
|
+
engineering-unit-converter
|
|
2
|
+
=============
|
|
3
|
+
|
|
4
|
+
A light and simple library for make all type measures conversions and manipulations.
|
|
5
|
+
Used [convert-units](https://github.com/ben-ng/convert-units) as a reference.
|
|
6
|
+
|
|
7
|
+
Installation
|
|
8
|
+
-----
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install engineering-unit-converter
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Usage
|
|
15
|
+
-----
|
|
16
|
+
|
|
17
|
+
`engineering-unit-converter` uses TypeScript to infer the available units, I strongly recommend using it for making the dev experience better.
|
|
18
|
+
|
|
19
|
+
Using this library is simple, the above snippet shows an example:
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
import { massFlow } from 'engineering-unit-converter'
|
|
23
|
+
const newValue = massFlow(65000).from('lb/day').to('kg/h')
|
|
24
|
+
console.log(newValue) //1228.4818798922718
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Available units
|
|
28
|
+
-----
|
|
29
|
+
|
|
30
|
+
- acceleration
|
|
31
|
+
- area
|
|
32
|
+
- density
|
|
33
|
+
- electricCharge
|
|
34
|
+
- electricCurrent
|
|
35
|
+
- energy
|
|
36
|
+
- force
|
|
37
|
+
- length
|
|
38
|
+
- massFlow
|
|
39
|
+
- mass
|
|
40
|
+
- massPerStandardVolume
|
|
41
|
+
- power
|
|
42
|
+
- pressureManometric
|
|
43
|
+
- pressure
|
|
44
|
+
- speed
|
|
45
|
+
- standardVolumetricFlow
|
|
46
|
+
- surfaceTension
|
|
47
|
+
- time
|
|
48
|
+
- viscosity
|
|
49
|
+
- voltage
|
|
50
|
+
- volume
|
|
50
51
|
- volumetricFlow
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var c = (
|
|
1
|
+
var m = Object.defineProperty;
|
|
2
|
+
var l = (r, e, n) => e in r ? m(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n;
|
|
3
|
+
var c = (r, e, n) => (l(r, typeof e != "symbol" ? e + "" : e, n), n);
|
|
4
4
|
class u {
|
|
5
|
-
constructor(e,
|
|
5
|
+
constructor(e, n) {
|
|
6
6
|
c(this, "_definitions");
|
|
7
7
|
c(this, "_val");
|
|
8
8
|
c(this, "_fromUnit", null);
|
|
9
|
-
this._definitions =
|
|
9
|
+
this._definitions = n, this._val = e;
|
|
10
10
|
}
|
|
11
11
|
from(e) {
|
|
12
12
|
return this._checkUnit(e), this._fromUnit = e, this;
|
|
@@ -15,24 +15,24 @@ class u {
|
|
|
15
15
|
if (!this._fromUnit)
|
|
16
16
|
throw new Error('Please specify the "from" unit using the from() method before calling to().');
|
|
17
17
|
this._checkUnit(e);
|
|
18
|
-
const
|
|
18
|
+
const n = this._getUnit(this._fromUnit), t = this._getUnit(e);
|
|
19
19
|
let o = this._val;
|
|
20
|
-
return
|
|
20
|
+
return n.offset !== 0 && (o -= n.offset), o = o * n.convertValue / t.convertValue, t.offset !== 0 && (o += t.offset), o;
|
|
21
21
|
}
|
|
22
22
|
_getUnit(e) {
|
|
23
|
-
const
|
|
24
|
-
return { convertValue:
|
|
23
|
+
const n = this._definitions.units[e], t = n.offset ?? 0;
|
|
24
|
+
return { convertValue: n.convertValue, offset: t };
|
|
25
25
|
}
|
|
26
26
|
_checkUnit(e) {
|
|
27
|
-
const
|
|
28
|
-
if (!
|
|
29
|
-
throw new Error(`Invalid unit "${e}". Available units: ${
|
|
27
|
+
const n = Object.keys(this._definitions.units);
|
|
28
|
+
if (!n.includes(e))
|
|
29
|
+
throw new Error(`Invalid unit "${e}". Available units: ${n.join(", ")}`);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
class s {
|
|
33
|
-
constructor(e,
|
|
33
|
+
constructor(e, n) {
|
|
34
34
|
c(this, "_internalConverter");
|
|
35
|
-
this._internalConverter = new u(e,
|
|
35
|
+
this._internalConverter = new u(e, n);
|
|
36
36
|
}
|
|
37
37
|
from(e) {
|
|
38
38
|
return this._internalConverter.from(e), new i(this._internalConverter);
|
|
@@ -46,7 +46,7 @@ class i {
|
|
|
46
46
|
return this._internalConverter.to(e);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
const
|
|
49
|
+
const a = (r) => (e) => new s(e, r), v = {
|
|
50
50
|
baseUnit: "m/s2",
|
|
51
51
|
units: {
|
|
52
52
|
"m/s2": {
|
|
@@ -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
|
+
}, B = a(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
|
+
}, N = a(V), p = {
|
|
118
118
|
baseUnit: "kg/m3",
|
|
119
119
|
units: {
|
|
120
120
|
"kg/m3": {
|
|
@@ -127,7 +127,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
127
127
|
},
|
|
128
128
|
"g/cm3": {
|
|
129
129
|
name: "Gram per cubic centimeter",
|
|
130
|
-
convertValue:
|
|
130
|
+
convertValue: 1e3
|
|
131
131
|
},
|
|
132
132
|
"kg/ft3": {
|
|
133
133
|
name: "Kilogram per cubic foot",
|
|
@@ -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
|
+
}, T = a(p), d = {
|
|
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
|
+
}, W = a(d), g = {
|
|
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
|
+
}, H = a(g), h = {
|
|
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
|
+
}, J = a(h), f = {
|
|
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
|
+
}, L = a(f), 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
|
+
}, O = a(b), C = {
|
|
299
299
|
baseUnit: "kg/s",
|
|
300
300
|
units: {
|
|
301
301
|
"kg/s": {
|
|
@@ -320,7 +320,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
320
320
|
},
|
|
321
321
|
"ton/day": {
|
|
322
322
|
name: "Ton per day",
|
|
323
|
-
convertValue:
|
|
323
|
+
convertValue: 0.011574074074074073
|
|
324
324
|
},
|
|
325
325
|
"oz/min": {
|
|
326
326
|
name: "Ounce per minute",
|
|
@@ -328,7 +328,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
328
328
|
},
|
|
329
329
|
"ton/year": {
|
|
330
330
|
name: "Ton per year",
|
|
331
|
-
convertValue:
|
|
331
|
+
convertValue: 31709791983764585e-21
|
|
332
332
|
},
|
|
333
333
|
"lb/s": {
|
|
334
334
|
name: "Pound per second",
|
|
@@ -340,7 +340,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
340
340
|
// 1 day = 86400 seconds
|
|
341
341
|
}
|
|
342
342
|
}
|
|
343
|
-
},
|
|
343
|
+
}, j = a(C), M = {
|
|
344
344
|
baseUnit: "kg",
|
|
345
345
|
units: {
|
|
346
346
|
kg: {
|
|
@@ -372,7 +372,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
372
372
|
convertValue: 1e-6
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
},
|
|
375
|
+
}, z = a(M), S = {
|
|
376
376
|
baseUnit: "W",
|
|
377
377
|
units: {
|
|
378
378
|
W: {
|
|
@@ -400,7 +400,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
400
400
|
// Conversion factor from W to cal/s
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
|
-
},
|
|
403
|
+
}, E = a(S), P = {
|
|
404
404
|
baseUnit: "Pag",
|
|
405
405
|
units: {
|
|
406
406
|
Pag: {
|
|
@@ -438,7 +438,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
438
438
|
// Conversion factor from Pa to kg/cm²
|
|
439
439
|
}
|
|
440
440
|
}
|
|
441
|
-
},
|
|
441
|
+
}, Y = a(P), k = {
|
|
442
442
|
baseUnit: "Pa",
|
|
443
443
|
units: {
|
|
444
444
|
Pa: {
|
|
@@ -475,46 +475,50 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
475
475
|
convertValue: 98066.5
|
|
476
476
|
// Conversion factor from Pa to kg/cm²
|
|
477
477
|
},
|
|
478
|
+
// Gauge units: 0 gauge is one atmosphere absolute. `offset` is expressed in
|
|
479
|
+
// the unit's OWN scale, so each one carries 101325 Pa converted into that
|
|
480
|
+
// unit, not the raw Pascal value.
|
|
478
481
|
Pag: {
|
|
479
|
-
name: "Pascal",
|
|
482
|
+
name: "Pascal Gauge",
|
|
480
483
|
convertValue: 1,
|
|
481
|
-
offset: -
|
|
484
|
+
offset: -101325
|
|
485
|
+
// 1 atm in Pa
|
|
482
486
|
},
|
|
483
487
|
kPag: {
|
|
484
|
-
name: "Kilopascal",
|
|
488
|
+
name: "Kilopascal Gauge",
|
|
485
489
|
convertValue: 1e3,
|
|
486
|
-
offset: -
|
|
487
|
-
//
|
|
490
|
+
offset: -101.325
|
|
491
|
+
// 1 atm in kPa
|
|
488
492
|
},
|
|
489
493
|
MPag: {
|
|
490
|
-
name: "Megapascal",
|
|
494
|
+
name: "Megapascal Gauge",
|
|
491
495
|
convertValue: 1e6,
|
|
492
|
-
offset: -
|
|
493
|
-
//
|
|
496
|
+
offset: -0.101325
|
|
497
|
+
// 1 atm in MPa
|
|
494
498
|
},
|
|
495
499
|
barg: {
|
|
496
|
-
name: "Bar",
|
|
500
|
+
name: "Bar Gauge",
|
|
497
501
|
convertValue: 1e5,
|
|
498
|
-
offset: -1
|
|
499
|
-
//
|
|
502
|
+
offset: -1.01325
|
|
503
|
+
// 1 atm in bar
|
|
500
504
|
},
|
|
501
505
|
atmg: {
|
|
502
|
-
name: "Atmosphere",
|
|
506
|
+
name: "Atmosphere Gauge",
|
|
503
507
|
convertValue: 101325,
|
|
504
508
|
offset: -1
|
|
505
|
-
//
|
|
509
|
+
// 1 atm in atm
|
|
506
510
|
},
|
|
507
511
|
psig: {
|
|
508
|
-
name: "Pound per Square Inch",
|
|
512
|
+
name: "Pound per Square Inch Gauge",
|
|
509
513
|
convertValue: 6894.76,
|
|
510
|
-
offset: -
|
|
511
|
-
//
|
|
514
|
+
offset: -101325 / 6894.76
|
|
515
|
+
// 1 atm in psi, 14.6959...
|
|
512
516
|
},
|
|
513
517
|
"kg/cm2g": {
|
|
514
|
-
name: "Kilogram per Square Centimeter",
|
|
518
|
+
name: "Kilogram per Square Centimeter Gauge",
|
|
515
519
|
convertValue: 98066.5,
|
|
516
|
-
offset: -
|
|
517
|
-
//
|
|
520
|
+
offset: -101325 / 98066.5
|
|
521
|
+
// 1 atm in kg/cm², 1.03323...
|
|
518
522
|
},
|
|
519
523
|
ksi: {
|
|
520
524
|
name: "1000 Pound per Square Inch",
|
|
@@ -522,7 +526,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
522
526
|
// Conversion factor from Pa to psi
|
|
523
527
|
}
|
|
524
528
|
}
|
|
525
|
-
},
|
|
529
|
+
}, x = a(k), K = {
|
|
526
530
|
baseUnit: "m/s",
|
|
527
531
|
units: {
|
|
528
532
|
"m/s": {
|
|
@@ -555,10 +559,10 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
555
559
|
},
|
|
556
560
|
mph: {
|
|
557
561
|
name: "Miles per hour",
|
|
558
|
-
convertValue:
|
|
562
|
+
convertValue: 0.44704
|
|
559
563
|
}
|
|
560
564
|
}
|
|
561
|
-
},
|
|
565
|
+
}, Q = a(K), y = {
|
|
562
566
|
baseUnit: "SCMD",
|
|
563
567
|
units: {
|
|
564
568
|
SCMD: {
|
|
@@ -601,7 +605,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
601
605
|
// Conversion factor from SCMD to MMSCFD
|
|
602
606
|
}
|
|
603
607
|
}
|
|
604
|
-
},
|
|
608
|
+
}, R = a(y), F = {
|
|
605
609
|
baseUnit: "N/m",
|
|
606
610
|
units: {
|
|
607
611
|
"N/m": {
|
|
@@ -629,7 +633,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
629
633
|
convertValue: 10.945427
|
|
630
634
|
}
|
|
631
635
|
}
|
|
632
|
-
},
|
|
636
|
+
}, X = a(F), U = {
|
|
633
637
|
baseUnit: "sec",
|
|
634
638
|
units: {
|
|
635
639
|
sec: {
|
|
@@ -662,7 +666,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
662
666
|
// Conversion factor from seconds to days
|
|
663
667
|
}
|
|
664
668
|
}
|
|
665
|
-
},
|
|
669
|
+
}, Z = a(U), q = {
|
|
666
670
|
baseUnit: "cP",
|
|
667
671
|
units: {
|
|
668
672
|
cP: {
|
|
@@ -690,7 +694,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
690
694
|
convertValue: 1 / 3.6
|
|
691
695
|
}
|
|
692
696
|
}
|
|
693
|
-
},
|
|
697
|
+
}, ee = a(q), $ = {
|
|
694
698
|
baseUnit: "V",
|
|
695
699
|
// transform: (val) => val * baseValue,
|
|
696
700
|
units: {
|
|
@@ -707,7 +711,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
707
711
|
convertValue: 1e3
|
|
708
712
|
}
|
|
709
713
|
}
|
|
710
|
-
},
|
|
714
|
+
}, ae = a($), w = {
|
|
711
715
|
baseUnit: "m3",
|
|
712
716
|
units: {
|
|
713
717
|
m3: {
|
|
@@ -743,7 +747,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
743
747
|
convertValue: 16387e-9
|
|
744
748
|
}
|
|
745
749
|
}
|
|
746
|
-
}, ne =
|
|
750
|
+
}, ne = a(w), _ = {
|
|
747
751
|
baseUnit: "m3/h",
|
|
748
752
|
units: {
|
|
749
753
|
"m3/h": {
|
|
@@ -783,7 +787,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
783
787
|
convertValue: 378541e-8 * 3600
|
|
784
788
|
}
|
|
785
789
|
}
|
|
786
|
-
},
|
|
790
|
+
}, re = a(_), G = {
|
|
787
791
|
baseUnit: "C",
|
|
788
792
|
units: {
|
|
789
793
|
C: {
|
|
@@ -804,7 +808,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
804
808
|
// Subtract 273.15 to convert from K to C
|
|
805
809
|
}
|
|
806
810
|
}
|
|
807
|
-
}, te =
|
|
811
|
+
}, te = a(G), D = {
|
|
808
812
|
baseUnit: "Pa/m",
|
|
809
813
|
units: {
|
|
810
814
|
"Pa/m": {
|
|
@@ -822,7 +826,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
822
826
|
// 1 kPa = 1000 Pa
|
|
823
827
|
},
|
|
824
828
|
"kPa/km": {
|
|
825
|
-
name: "Kilopascal per
|
|
829
|
+
name: "Kilopascal per Kilometer",
|
|
826
830
|
convertValue: 1
|
|
827
831
|
},
|
|
828
832
|
"bar/m": {
|
|
@@ -837,7 +841,7 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
837
841
|
},
|
|
838
842
|
"psi/ft": {
|
|
839
843
|
name: "Pound per Square Inch per Foot",
|
|
840
|
-
convertValue:
|
|
844
|
+
convertValue: 22620.594793858265
|
|
841
845
|
// 1 psi = 6894.76 Pa, 1 ft = 0.3048 m
|
|
842
846
|
},
|
|
843
847
|
"psi/m": {
|
|
@@ -865,61 +869,112 @@ const n = (t) => (e) => new s(e, t), v = {
|
|
|
865
869
|
convertValue: 98.0665
|
|
866
870
|
// 1 kg/cm² = 98066.5 Pa / 1000 m
|
|
867
871
|
},
|
|
868
|
-
// Gauge
|
|
872
|
+
// Gauge gradients. No offset: a gradient is a pressure DIFFERENCE per
|
|
873
|
+
// length, so the atmospheric datum cancels — 1 barg/m is exactly
|
|
874
|
+
// 1 bar/m. These keys are aliases of their absolute counterparts.
|
|
869
875
|
"barg/m": {
|
|
870
876
|
name: "Bar Gauge per Meter",
|
|
871
|
-
convertValue: 1e5
|
|
872
|
-
|
|
873
|
-
// Remove atmospheric pressure
|
|
877
|
+
convertValue: 1e5
|
|
878
|
+
// 1 bar = 100,000 Pa
|
|
874
879
|
},
|
|
875
880
|
"psig/ft": {
|
|
876
881
|
name: "Pound per Square Inch Gauge per Foot",
|
|
877
|
-
convertValue:
|
|
878
|
-
|
|
879
|
-
// Remove atmospheric pressure in Pa
|
|
882
|
+
convertValue: 22620.594793858265
|
|
883
|
+
// 1 psi = 6894.76 Pa, 1 ft = 0.3048 m
|
|
880
884
|
},
|
|
881
885
|
"psig/m": {
|
|
882
886
|
name: "Pound per Square Inch Gauge per Meter",
|
|
883
|
-
convertValue: 6894.76
|
|
884
|
-
|
|
885
|
-
// Remove atmospheric pressure in Pa
|
|
887
|
+
convertValue: 6894.76
|
|
888
|
+
// 1 psi = 6894.76 Pa
|
|
886
889
|
},
|
|
887
890
|
"kg/cm2g/m": {
|
|
888
891
|
name: "Kilogram per Square Centimeter Gauge per Meter",
|
|
889
|
-
convertValue: 98066.5
|
|
890
|
-
|
|
891
|
-
// Remove atmospheric pressure in Pa
|
|
892
|
+
convertValue: 98066.5
|
|
893
|
+
// 1 kg/cm² = 98066.5 Pa
|
|
892
894
|
},
|
|
893
895
|
"kg/cm2g/km": {
|
|
894
896
|
name: "Kilogram per Square Centimeter Gauge per Kilometer",
|
|
895
|
-
convertValue: 98.0665
|
|
896
|
-
|
|
897
|
-
|
|
897
|
+
convertValue: 98.0665
|
|
898
|
+
// 1 kg/cm² = 98066.5 Pa / 1000 m
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}, oe = a(D), I = {
|
|
902
|
+
baseUnit: "kg/Sm3",
|
|
903
|
+
units: {
|
|
904
|
+
"kg/Sm3": {
|
|
905
|
+
name: "Kilogram per Standard Cubic Meter",
|
|
906
|
+
convertValue: 1
|
|
907
|
+
},
|
|
908
|
+
"g/Sm3": {
|
|
909
|
+
name: "Gram per Standard Cubic Meter",
|
|
910
|
+
convertValue: 1e-3
|
|
911
|
+
// 1 g = 0.001 kg
|
|
912
|
+
},
|
|
913
|
+
"mg/Sm3": {
|
|
914
|
+
name: "Milligram per Standard Cubic Meter",
|
|
915
|
+
convertValue: 1e-6
|
|
916
|
+
// 1 mg = 1e-6 kg
|
|
917
|
+
},
|
|
918
|
+
"kg/MSm3": {
|
|
919
|
+
name: "Kilogram per Thousand Standard Cubic Meters",
|
|
920
|
+
convertValue: 1 / 1e3
|
|
921
|
+
// M = thousand Sm3
|
|
922
|
+
},
|
|
923
|
+
"kg/MMSm3": {
|
|
924
|
+
name: "Kilogram per Million Standard Cubic Meters",
|
|
925
|
+
convertValue: 1 / 1e6
|
|
926
|
+
// MM = million Sm3
|
|
927
|
+
},
|
|
928
|
+
"g/SCF": {
|
|
929
|
+
name: "Gram per Standard Cubic Foot",
|
|
930
|
+
convertValue: 1e-3 * 35.3147
|
|
931
|
+
// 1 g = 0.001 kg, 1 Sm3 = 35.3147 SCF
|
|
932
|
+
},
|
|
933
|
+
"lb/SCF": {
|
|
934
|
+
name: "Pound per Standard Cubic Foot",
|
|
935
|
+
convertValue: 0.453592 * 35.3147
|
|
936
|
+
// 1 lb = 0.453592 kg, 1 Sm3 = 35.3147 SCF
|
|
937
|
+
},
|
|
938
|
+
"lb/MSCF": {
|
|
939
|
+
name: "Pound per Thousand Standard Cubic Feet",
|
|
940
|
+
convertValue: 0.453592 * 35.3147 / 1e3
|
|
941
|
+
// M = thousand SCF
|
|
942
|
+
},
|
|
943
|
+
"lb/MMSCF": {
|
|
944
|
+
name: "Pound per Million Standard Cubic Feet",
|
|
945
|
+
convertValue: 0.453592 * 35.3147 / 1e6
|
|
946
|
+
// MM = million SCF
|
|
947
|
+
},
|
|
948
|
+
"kg/MMSCF": {
|
|
949
|
+
name: "Kilogram per Million Standard Cubic Feet",
|
|
950
|
+
convertValue: 35.3147 / 1e6
|
|
951
|
+
// Conversion factor from kg/Sm3 to kg/MMSCF
|
|
898
952
|
}
|
|
899
953
|
}
|
|
900
|
-
},
|
|
954
|
+
}, ce = a(I);
|
|
901
955
|
export {
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
Q as
|
|
956
|
+
B as acceleration,
|
|
957
|
+
N as area,
|
|
958
|
+
T as density,
|
|
959
|
+
W as electricCharge,
|
|
960
|
+
H as electricCurrent,
|
|
961
|
+
J as energy,
|
|
962
|
+
L as force,
|
|
963
|
+
O as length,
|
|
964
|
+
z as mass,
|
|
965
|
+
j as massFlow,
|
|
966
|
+
ce as massPerStandardVolume,
|
|
967
|
+
E as power,
|
|
968
|
+
x as pressure,
|
|
969
|
+
Y as pressureManometric,
|
|
970
|
+
oe as pressurePerLength,
|
|
971
|
+
Q as speed,
|
|
972
|
+
R as standardVolumetricFlow,
|
|
918
973
|
te as temperature,
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
974
|
+
Z as time,
|
|
975
|
+
X as torque,
|
|
976
|
+
ee as viscosity,
|
|
977
|
+
ae as voltage,
|
|
923
978
|
ne as volume,
|
|
924
|
-
|
|
979
|
+
re as volumetricFlow
|
|
925
980
|
};
|
|
@@ -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 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},mg:{name:"Miligram",convertValue:1e-6}}}),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},ft3:{name:"Cubic Feet",convertValue:.0283168},in3:{name:"Cubic inch",convertValue:16387e-9}}},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},"kPa/km":{name:"Kilopascal per Meter",convertValue:1},"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"})});
|
|
1
|
+
(function(e,r){typeof exports=="object"&&typeof module<"u"?r(exports):typeof define=="function"&&define.amd?define(["exports"],r):(e=typeof globalThis<"u"?globalThis:e||self,r(e["engineering-unit-converter"]={}))})(this,function(e){"use strict";var Z=Object.defineProperty;var x=(e,r,o)=>r in e?Z(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o;var l=(e,r,o)=>(x(e,typeof r!="symbol"?r+"":r,o),o);class r{constructor(a,t){l(this,"_definitions");l(this,"_val");l(this,"_fromUnit",null);this._definitions=t,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 t=this._getUnit(this._fromUnit),c=this._getUnit(a);let u=this._val;return t.offset!==0&&(u-=t.offset),u=u*t.convertValue/c.convertValue,c.offset!==0&&(u+=c.offset),u}_getUnit(a){const t=this._definitions.units[a],c=t.offset??0;return{convertValue:t.convertValue,offset:c}}_checkUnit(a){const t=Object.keys(this._definitions.units);if(!t.includes(a))throw new Error(`Invalid unit "${a}". Available units: ${t.join(", ")}`)}}class o{constructor(a,t){l(this,"_internalConverter");this._internalConverter=new r(a,t)}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),p={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:1e3},"kg/ft3":{name:"Kilogram per cubic foot",convertValue:1/.0283168},"lb/m3":{name:"Pound per cubic meter",convertValue:1/2.20462}}},g=n(p),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}}}),f=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}}},S=n(M),P=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:.011574074074074073},"oz/min":{name:"Ounce per minute",convertValue:1/2116.4394433764},"ton/year":{name:"Ton per year",convertValue:31709791983764585e-21},"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},mg:{name:"Miligram",convertValue:1e-6}}}),F={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}}},U=n(F),q=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}}}),$={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 Gauge",convertValue:1,offset:-101325},kPag:{name:"Kilopascal Gauge",convertValue:1e3,offset:-101.325},MPag:{name:"Megapascal Gauge",convertValue:1e6,offset:-.101325},barg:{name:"Bar Gauge",convertValue:1e5,offset:-1.01325},atmg:{name:"Atmosphere Gauge",convertValue:101325,offset:-1},psig:{name:"Pound per Square Inch Gauge",convertValue:6894.76,offset:-101325/6894.76},"kg/cm2g":{name:"Kilogram per Square Centimeter Gauge",convertValue:98066.5,offset:-101325/98066.5},ksi:{name:"1000 Pound per Square Inch",convertValue:6894.76*1e3}}},w=n($),_={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:.44704}}},G=n(_),D={baseUnit:"SCMD",units:{SCMD:{name:"Standard Cubic Meters per Day",convertValue:1},SCFD:{name:"Standard Cubic Feet per Day",convertValue:1/35.3147},MSCMD:{name:"Million Standard Cubic Meters per Day",convertValue:1e3},MMSCMD:{name:"Million Million Standard Cubic Meters per Day",convertValue:1e6},MSCFD:{name:"Million Standard Cubic Feet per Day",convertValue:1/35.3147*1e3},MMSCFD:{name:"Million Million Standard Cubic Feet per Day",convertValue:1/35.3147*1e6},"Sm3/h":{name:"Standard Cubic Meter per Hour",convertValue:24},"Sft3/h":{name:"Standard Cubic Feet per Hour",convertValue:1/35.3147*24}}},I=n(D),A=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),N={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(N),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},ft3:{name:"Cubic Feet",convertValue:.0283168},in3:{name:"Cubic inch",convertValue:16387e-9}}},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},"kPa/km":{name:"Kilopascal per Kilometer",convertValue:1},"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:22620.594793858265},"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},"psig/ft":{name:"Pound per Square Inch Gauge per Foot",convertValue:22620.594793858265},"psig/m":{name:"Pound per Square Inch Gauge per Meter",convertValue:6894.76},"kg/cm2g/m":{name:"Kilogram per Square Centimeter Gauge per Meter",convertValue:98066.5},"kg/cm2g/km":{name:"Kilogram per Square Centimeter Gauge per Kilometer",convertValue:98.0665}}},Q=n(Y),R={baseUnit:"kg/Sm3",units:{"kg/Sm3":{name:"Kilogram per Standard Cubic Meter",convertValue:1},"g/Sm3":{name:"Gram per Standard Cubic Meter",convertValue:.001},"mg/Sm3":{name:"Milligram per Standard Cubic Meter",convertValue:1e-6},"kg/MSm3":{name:"Kilogram per Thousand Standard Cubic Meters",convertValue:1/1e3},"kg/MMSm3":{name:"Kilogram per Million Standard Cubic Meters",convertValue:1/1e6},"g/SCF":{name:"Gram per Standard Cubic Foot",convertValue:.001*35.3147},"lb/SCF":{name:"Pound per Standard Cubic Foot",convertValue:.453592*35.3147},"lb/MSCF":{name:"Pound per Thousand Standard Cubic Feet",convertValue:.453592*35.3147/1e3},"lb/MMSCF":{name:"Pound per Million Standard Cubic Feet",convertValue:.453592*35.3147/1e6},"kg/MMSCF":{name:"Kilogram per Million Standard Cubic Feet",convertValue:35.3147/1e6}}},X=n(R);e.acceleration=v,e.area=d,e.density=g,e.electricCharge=h,e.electricCurrent=f,e.energy=C,e.force=S,e.length=P,e.mass=K,e.massFlow=y,e.massPerStandardVolume=X,e.power=U,e.pressure=w,e.pressureManometric=q,e.pressurePerLength=Q,e.speed=G,e.standardVolumetricFlow=I,e.temperature=E,e.time=B,e.torque=A,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
|
@@ -21,3 +21,4 @@ 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
23
|
export { default as pressurePerLength } from './units/pressure-per-length';
|
|
24
|
+
export { default as massPerStandardVolume } from './units/mass-per-standard-volume';
|
package/dist/types.d.ts
CHANGED
|
@@ -296,6 +296,22 @@ export type StandardVolumetricFlow = {
|
|
|
296
296
|
baseUnit: 'SCMD';
|
|
297
297
|
units: StandardVolumetricFlowUnits;
|
|
298
298
|
};
|
|
299
|
+
export type MassPerStandardVolumeUnits = {
|
|
300
|
+
'kg/Sm3': UnitsValues;
|
|
301
|
+
'g/Sm3': UnitsValues;
|
|
302
|
+
'mg/Sm3': UnitsValues;
|
|
303
|
+
'kg/MSm3': UnitsValues;
|
|
304
|
+
'kg/MMSm3': UnitsValues;
|
|
305
|
+
'g/SCF': UnitsValues;
|
|
306
|
+
'lb/SCF': UnitsValues;
|
|
307
|
+
'lb/MSCF': UnitsValues;
|
|
308
|
+
'lb/MMSCF': UnitsValues;
|
|
309
|
+
'kg/MMSCF': UnitsValues;
|
|
310
|
+
};
|
|
311
|
+
export type MassPerStandardVolume = {
|
|
312
|
+
baseUnit: 'kg/Sm3';
|
|
313
|
+
units: MassPerStandardVolumeUnits;
|
|
314
|
+
};
|
|
299
315
|
export type TemperatureUnits = {
|
|
300
316
|
'C': UnitsValues;
|
|
301
317
|
'F': UnitsValues;
|
|
@@ -305,7 +321,7 @@ export type Temperature = {
|
|
|
305
321
|
baseUnit: 'C';
|
|
306
322
|
units: TemperatureUnits;
|
|
307
323
|
};
|
|
308
|
-
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;
|
|
324
|
+
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 | MassPerStandardVolume;
|
|
309
325
|
export type MeasurementUnits<T extends Measurement> = T extends {
|
|
310
326
|
units: infer U;
|
|
311
327
|
} ? keyof U : never;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type MassPerStandardVolume } from '../types';
|
|
2
|
+
declare const _default: (val: number) => {
|
|
3
|
+
readonly _internalConverter: import("../internalConverter").default<MassPerStandardVolume>;
|
|
4
|
+
from<U extends keyof import("../types").MassPerStandardVolumeUnits>(fromUnit: U): {
|
|
5
|
+
readonly _internalConverter: import("../internalConverter").default<MassPerStandardVolume>;
|
|
6
|
+
to<U_1 extends keyof import("../types").MassPerStandardVolumeUnits>(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.
|
|
7
|
+
"version": "0.0.16",
|
|
8
8
|
"keywords": [
|
|
9
9
|
"units",
|
|
10
10
|
"engineering",
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"scripts": {
|
|
32
32
|
"dev": "vite",
|
|
33
33
|
"build": "tsc && vite build",
|
|
34
|
-
"preview": "vite preview"
|
|
34
|
+
"preview": "vite preview",
|
|
35
|
+
"test": "vitest run",
|
|
36
|
+
"test:watch": "vitest"
|
|
35
37
|
},
|
|
36
38
|
"devDependencies": {
|
|
37
39
|
"@changesets/cli": "^2.27.1",
|
|
@@ -41,12 +43,13 @@
|
|
|
41
43
|
"eslint-plugin-import": "^2.29.0",
|
|
42
44
|
"eslint-plugin-n": "^16.3.1",
|
|
43
45
|
"eslint-plugin-promise": "^6.1.1",
|
|
46
|
+
"tsx": "^4.19.1",
|
|
44
47
|
"typescript": "^5.3.2",
|
|
45
48
|
"vite": "^5.0.0",
|
|
46
49
|
"vite-plugin-dts": "^3.6.4",
|
|
47
|
-
"
|
|
50
|
+
"vitest": "^2.1.9"
|
|
48
51
|
},
|
|
49
52
|
"publishConfig": {
|
|
50
53
|
"access": "public"
|
|
51
54
|
}
|
|
52
|
-
}
|
|
55
|
+
}
|