@oliasoft-open-source/units 5.9.0 → 5.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3291 +0,0 @@
1
- //#region \0rolldown/runtime.js
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __commonJSMin = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
11
- key = keys[i];
12
- if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
13
- get: ((k) => from[k]).bind(null, key),
14
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
15
- });
16
- }
17
- return to;
18
- };
19
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
20
- value: mod,
21
- enumerable: true
22
- }) : target, mod));
23
- //#endregion
24
- let fraction_js = require("fraction.js");
25
- fraction_js = __toESM(fraction_js, 1);
26
- //#region src/numbers/statistics/confidence-interval.ts
27
- const { abs, exp, sqrt } = Math;
28
- /** Applies the one-dimensional iterative Newton method. */
29
- function newton(functionValue, derivative, initialValue, tolerance = 1e-8, maxIterations = 30) {
30
- let currentValue = initialValue;
31
- let iteration = 0;
32
- let error = 1;
33
- while (error > tolerance && iteration < maxIterations) {
34
- const nextValue = currentValue - functionValue(currentValue) / derivative(currentValue);
35
- error = abs(functionValue(nextValue) - functionValue(currentValue));
36
- if (error < tolerance) return [
37
- nextValue,
38
- true,
39
- iteration
40
- ];
41
- currentValue = nextValue;
42
- iteration += 1;
43
- }
44
- return [
45
- initialValue,
46
- false,
47
- iteration
48
- ];
49
- }
50
- /** Approximates the Gaussian error function. */
51
- function erf(value) {
52
- const t = 1 / (1 + .5 * abs(value));
53
- const answer = 1 - t * exp(-(value ** 2) - 1.26551223 + t * (1.00002368 + t * (.37409196 + t * (.09678418 + t * (-.18628806 + t * (.27886807 + t * (-1.13520398 + t * (1.48851587 + t * (-.82215223 + t * .17087277)))))))));
54
- return value >= 0 ? answer : -answer;
55
- }
56
- /** Converts a confidence interval to a number of standard deviations. */
57
- function get_k_from_conf_int(confidenceInterval) {
58
- const functionValue = (value) => {
59
- return confidenceInterval - erf(value / sqrt(2));
60
- };
61
- const derivative = (value) => {
62
- return -sqrt(2 / Math.PI) * exp(-.5 * value ** 2);
63
- };
64
- const [result] = newton(functionValue, derivative, 1);
65
- return result;
66
- }
67
- /** Converts a number of standard deviations to a confidence interval. */
68
- function get_conf_int_from_k(standardDeviations) {
69
- return erf(standardDeviations / sqrt(2));
70
- }
71
- //#endregion
72
- //#region src/units/constants.ts
73
- /**
74
- * Units labels
75
- *
76
- * @readonly
77
- * @enum {Object}
78
- */
79
- const LABELS = Object.freeze({
80
- in: "in",
81
- mm: "mm",
82
- cm: "cm",
83
- m: "m",
84
- microM: "μm",
85
- km: "km",
86
- ft: "ft",
87
- usft: "usft",
88
- in2: "in²",
89
- cm2: "cm²",
90
- m2: "m²",
91
- kg: "kg",
92
- tonnes: "t",
93
- mt: "mt",
94
- kip: "kip",
95
- bbl: "bbl",
96
- m3: "m³",
97
- Mm3: "Mm³",
98
- MMSCF: "MMSCF",
99
- lbm: "lbm",
100
- "kg/mol": "kg/mol",
101
- "lbf/mol": "lbf/mol",
102
- sg: "sg",
103
- ppg: "ppg",
104
- "kg/m3": "kg/m³",
105
- "lbm/ft3": "lbm/ft³",
106
- s: "s",
107
- min: "min",
108
- h: "h",
109
- d: "d",
110
- month: "month",
111
- year: "year",
112
- "bbl/ft": "bbl/ft",
113
- lpm: "L/min",
114
- lps: "L/s",
115
- bpm: "bbl/min",
116
- "m3/min": "m³/min",
117
- "m3/s": "m³/s",
118
- MMSCFD: "MMSCFD",
119
- bar: "Bar",
120
- Pa: "Pa",
121
- kPa: "kPa",
122
- MPa: "MPa",
123
- GPa: "GPa",
124
- kPsi: "Psi",
125
- ksi: "ksi",
126
- "lbf/100ft2": "lbf/100ft²",
127
- "1/Pa": "Pa⁻¹",
128
- "1/kPa": "kPa⁻¹",
129
- "1/MPa": "MPa⁻¹",
130
- "1/GPa": "GPa⁻¹",
131
- "1/psi": "psi⁻¹",
132
- "kPa/m": "kPa/m",
133
- "1/bar": "bar⁻¹",
134
- klbf: "klbf",
135
- "psi/ft": "Psi/ft",
136
- "bar/100m": "bar/100m",
137
- "psi/100ft": "psi/100ft",
138
- "kPa/100m": "kPa/100m",
139
- C: "°C",
140
- F: "°F",
141
- K: "K",
142
- "C/100m": "°C/100m",
143
- "C/m": "°C/m",
144
- "Pa/C": "Pa/°C",
145
- "Bar/C": "Bar/°C",
146
- "psi/F": "psi/°F",
147
- "psi/C": "psi/°C",
148
- "F/100ft": "°F/100ft",
149
- "F/ft": "°F/ft",
150
- "K/100m": "K/100m",
151
- "K/m": "K/m",
152
- "lbf/ft": "lbf/ft",
153
- N: "N",
154
- kN: "kN",
155
- "N/m": "N/m",
156
- "daN/m": "daN/m",
157
- lbf: "lbf",
158
- kgf: "kgf",
159
- rad: "rad",
160
- "BTU/lbm": "BTU/lbm",
161
- ppf: "ppf",
162
- "kg/m": "kg/m",
163
- "E-06/degC": "10⁻⁶/°C",
164
- "E-06/degF": "10⁻⁶/°F",
165
- "1/K": "K⁻¹",
166
- km2: "km²",
167
- ft2: "ft²",
168
- mm2: "mm²",
169
- mile2: "mile²",
170
- ft3: "ft³",
171
- "g/cm3": "g/cm³",
172
- Sm3: "Sm³",
173
- "ft3/s": "ft³/s",
174
- "ft3/d": "ft³/d",
175
- "m3/d": "m³/d",
176
- "1/m3/d": "1/m³/d",
177
- "s/m3": "s/m³",
178
- "1/MMSCFD": "1/MMSCFD",
179
- "bbl/d": "bbl/d",
180
- tonneForce: "tonne-force",
181
- USGal: "US gal",
182
- "g/mol": "g/mol",
183
- Nm: "N⋅m",
184
- kNm: "kN⋅m",
185
- ftlbf: "ft⋅lbf",
186
- "J/(kg*degC)": "J/(kg⋅°C)",
187
- "J/(kg*degK)": "J/(kg⋅K)",
188
- "J/(s*m*degK)": "J/(s⋅m⋅K)",
189
- "BTU/(lbm*degF)": "BTU/(lbm⋅°F)",
190
- "BTU/(h*ft*degF)": "BTU/(h⋅ft⋅°F)",
191
- l: "L",
192
- "l/m": "L/m",
193
- "kJ/kg": "kJ/kg",
194
- "J/kg": "J/kg",
195
- deg: "°",
196
- "W/(mK)": "W/(m⋅K)",
197
- psi: "psi",
198
- "deg/100ft": "°/100ft",
199
- "deg/30m": "°/30m",
200
- "deg/10m": "°/10m",
201
- "%": "%",
202
- Hz: "Hz",
203
- "1/s": "1/s",
204
- rpm: "rpm",
205
- "Pa/m": "Pa/m",
206
- "bar/m": "bar/m",
207
- gpm: "gpm",
208
- "kg/s": "kg/s",
209
- "lbm/s": "lbm/s",
210
- "tonnes/h": "tonnes/h",
211
- "tons/h": "tons/h",
212
- "deg/m": "°/m",
213
- "deg/ft": "°/ft",
214
- "rad/m": "rad/m",
215
- "rad/ft": "rad/ft",
216
- "dyn/cm": "dyn/cm",
217
- "mN/m": "mN/m",
218
- "m/s": "m/s",
219
- "ft/s": "ft/s",
220
- "m/min": "m/min",
221
- "ft/min": "ft/min",
222
- "m/h": "m/h",
223
- "ft/h": "ft/h",
224
- mph: "mph",
225
- "km/h": "km/h",
226
- "m/s2": "m/s²",
227
- Gs: "Gs",
228
- nT: "nT",
229
- g: "g",
230
- "ft/s2": "ft/s²",
231
- "Pa*s": "Pa⋅s",
232
- P: "P",
233
- "mPa*s": "mPa⋅s",
234
- cP: "cP",
235
- W: "W",
236
- hhp: "hhp",
237
- hp: "hp",
238
- kW: "kW",
239
- MW: "MW",
240
- "BTU/h": "BTU/h",
241
- "W/m2": "W/m²",
242
- "hhp/in2": "hhp/in²",
243
- "hhp/ft2": "hhp/ft²",
244
- "Mm3/d": "Mm³/d",
245
- "STB/d": "STB/d",
246
- "Sm3/d": "Sm³/d",
247
- "Sm3/min": "Sm³/min",
248
- "MSm3/d": "MSm³/d",
249
- "SCF/STB": "SCF / STB",
250
- "Sm3/Sm3": "Sm³ / Sm³",
251
- "SCF/d": "SCF/d",
252
- STB: "STB",
253
- SCF: "SCF",
254
- MSm3: "MSm³",
255
- Gsg: "sg",
256
- Gppg: "ppg",
257
- "Gkg/m3": "kg/m³",
258
- "Glbm/ft3": "lbm/ft³",
259
- "lb/ft3": "lb/ft³",
260
- "°N": "°N",
261
- "°S": "°S",
262
- "°W": "°W",
263
- "°E": "°E",
264
- fr: " ",
265
- mD: "mD",
266
- CI: "CI",
267
- Sigma: "σ",
268
- "Sm3/d/bar": "Sm³/d/bar",
269
- "STB/d/psi": "STB/d/psi",
270
- "m3/s/bar": "m³/s/bar",
271
- "lb/ft": "lb/ft",
272
- "E-09/bar": "10⁻⁹/bar",
273
- "E-10/psi": "10⁻¹⁰/psi",
274
- "E-14/pa": "10⁻¹⁴/pa",
275
- "m3/m": " m³/m",
276
- "cm3/m": "cm³/m",
277
- "mm3/m": "mm³/m",
278
- "ft3/ft": "ft³/ft",
279
- "in3/ft": "in³/ft",
280
- lk: "lk",
281
- ftCla: "ftCla",
282
- lkCla: "lkCla",
283
- ftSe: "ftSe",
284
- ydSe: "ydSe",
285
- chSe: "chSe",
286
- "chSe(T)": "chSe(T)",
287
- ftGC: "ftGC",
288
- ydInd: "ydInd",
289
- "d/stand": "d/stand",
290
- "h/stand": "h/stand",
291
- "min/stand": "min/stand",
292
- "s/stand": "s/stand",
293
- "m3/t": "m3/t",
294
- "L/100kg": "L/100kg",
295
- "deg/h": "°/h"
296
- });
297
- /**
298
- * Alternative units grouped by quantity
299
- *
300
- * @readonly
301
- * @enum {Object}
302
- */
303
- const ALT_UNITS = Object.freeze({
304
- acceleration: ["ft/s2", "m/s2"],
305
- angleGradient: [
306
- "deg/30m",
307
- "rad/m",
308
- "deg/m",
309
- "deg/ft",
310
- "rad/ft",
311
- "deg/100ft",
312
- "deg/10m"
313
- ],
314
- angles: ["deg", "rad"],
315
- areaOther: [
316
- "in2",
317
- "ft2",
318
- "mm2",
319
- "cm2",
320
- "m2",
321
- "mile2",
322
- "km2"
323
- ],
324
- areaTubular: [
325
- "in2",
326
- "cm2",
327
- "ft2",
328
- "m2"
329
- ],
330
- blowoutFlowRate: [
331
- "lpm",
332
- "bpm",
333
- "m3/min",
334
- "ft3/s",
335
- "m3/s",
336
- "MMSCFD",
337
- "ft3/d",
338
- "m3/d",
339
- "bbl/d",
340
- "Mm3/d",
341
- "STB/d",
342
- "Sm3/d",
343
- "Sm3/min",
344
- "MSm3/d",
345
- "SCF/d"
346
- ],
347
- blowoutGasFlowRate: [
348
- "MMSCFD",
349
- "Sm3/d",
350
- "MSm3/d",
351
- "SCF/d"
352
- ],
353
- blowoutOilFlowRate: [
354
- "Sm3/d",
355
- "Sm3/min",
356
- "STB/d"
357
- ],
358
- deg: ["deg", "rad"],
359
- density: [
360
- "sg",
361
- "ppg",
362
- "kg/m3",
363
- "lbm/ft3",
364
- "g/cm3",
365
- "lb/ft3",
366
- "kPa/m"
367
- ],
368
- densityGas: [
369
- "Gsg",
370
- "Gppg",
371
- "Gkg/m3",
372
- "Glbm/ft3"
373
- ],
374
- densityOil: [
375
- "sg",
376
- "ppg",
377
- "kg/m3",
378
- "lbm/ft3"
379
- ],
380
- densityOilGas: [
381
- "ppg",
382
- "kg/m3",
383
- "lbm/ft3"
384
- ],
385
- densitySolid: [
386
- "sg",
387
- "ppg",
388
- "kg/m3",
389
- "lbm/ft3"
390
- ],
391
- depth: ["m", "ft"],
392
- diameters: [
393
- "in",
394
- "m",
395
- "cm",
396
- "ft",
397
- "mm"
398
- ],
399
- distance: ["m", "ft"],
400
- dls: [
401
- "deg/10m",
402
- "deg/30m",
403
- "deg/100ft"
404
- ],
405
- doglegSeverity: [
406
- "deg/10m",
407
- "deg/30m",
408
- "deg/100ft"
409
- ],
410
- duration: [
411
- "s",
412
- "h",
413
- "d",
414
- "min"
415
- ],
416
- durationShort: [
417
- "s",
418
- "min",
419
- "h",
420
- "d"
421
- ],
422
- durationLong: [
423
- "min",
424
- "h",
425
- "d",
426
- "month",
427
- "year"
428
- ],
429
- flowrate: [
430
- "lpm",
431
- "gpm",
432
- "bpm",
433
- "ft3/d",
434
- "ft3/s",
435
- "m3/s",
436
- "m3/d",
437
- "m3/min",
438
- "Mm3/d",
439
- "bbl/d",
440
- "MMSCFD",
441
- "STB/d",
442
- "Sm3/d",
443
- "Sm3/min",
444
- "MSm3/d",
445
- "SCF/d"
446
- ],
447
- fluidCompressibility: [
448
- "1/bar",
449
- "1/psi",
450
- "1/Pa",
451
- "1/kPa",
452
- "1/MPa",
453
- "1/GPa"
454
- ],
455
- force: [
456
- "tonnes",
457
- "lbf",
458
- "kgf",
459
- "N",
460
- "kN",
461
- "tonneForce",
462
- "klbf"
463
- ],
464
- forceGradient: ["lbf/ft", "N/m"],
465
- frequency: ["Hz"],
466
- gasVolume: [
467
- "MMSCF",
468
- "Sm3",
469
- "MSm3",
470
- "SCF"
471
- ],
472
- gor: ["Sm3/Sm3", "SCF/STB"],
473
- height: ["m", "ft"],
474
- intensity: [
475
- "W/m2",
476
- "hhp/in2",
477
- "hhp/ft2"
478
- ],
479
- interfacialTension: [
480
- "dyn/cm",
481
- "N/m",
482
- "lbf/ft",
483
- "mN/m"
484
- ],
485
- latitude: ["°N", "°S"],
486
- length: [
487
- "m",
488
- "cm",
489
- "ft",
490
- "km",
491
- "in",
492
- "mm"
493
- ],
494
- linearCapacity: ["l/m", "bbl/ft"],
495
- longitude: ["°E", "°W"],
496
- massFlowRate: [
497
- "kg/s",
498
- "lbm/s",
499
- "tonnes/h",
500
- "tons/h"
501
- ],
502
- moleWeight: [
503
- "kg/mol",
504
- "lbf/mol",
505
- "g/mol"
506
- ],
507
- oilVolume: ["STB", "Sm3"],
508
- percentage: ["%", "fr"],
509
- permeability: ["mD", "m2"],
510
- power: [
511
- "hp",
512
- "W",
513
- "hhp",
514
- "MW",
515
- "kW",
516
- "BTU/h"
517
- ],
518
- pressure: [
519
- "bar",
520
- "psi",
521
- "Pa",
522
- "kPa",
523
- "MPa",
524
- "ksi",
525
- "GPa",
526
- "lbf/100ft2"
527
- ],
528
- pressureGradient: [
529
- "bar/100m",
530
- "Pa/m",
531
- "bar/m",
532
- "psi/100ft",
533
- "psi/ft",
534
- "kPa/m"
535
- ],
536
- pressurechange: [
537
- "bar",
538
- "psi",
539
- "Pa",
540
- "MPa",
541
- "kPa"
542
- ],
543
- gasliftFlowRate: [
544
- "STB/d",
545
- "Sm3/d",
546
- "SCF/d"
547
- ],
548
- productionFlowRate: [
549
- "MMSCFD",
550
- "STB/d",
551
- "Sm3/d",
552
- "Sm3/min",
553
- "MSm3/d",
554
- "SCF/d"
555
- ],
556
- productionFlowRateOil: [
557
- "MMSCFD",
558
- "STB/d",
559
- "Sm3/d",
560
- "Sm3/min",
561
- "MSm3/d",
562
- "SCF/d"
563
- ],
564
- productionFlowRateGas: [
565
- "MMSCFD",
566
- "STB/d",
567
- "Sm3/d",
568
- "MSm3/d",
569
- "SCF/d"
570
- ],
571
- injectionFlowRate: [
572
- "lpm",
573
- "lps",
574
- "bpm",
575
- "gpm",
576
- "MMSCFD",
577
- "STB/d",
578
- "Sm3/d",
579
- "Sm3/min",
580
- "MSm3/d",
581
- "SCF/d"
582
- ],
583
- pumpRate: [
584
- "lpm",
585
- "lps",
586
- "bpm",
587
- "m3/s",
588
- "Sm3/min",
589
- "ft3/s",
590
- "gpm"
591
- ],
592
- rotationalSpeed: ["rpm", "Hz"],
593
- rotationalRate: ["deg/h"],
594
- roughness: [
595
- "m",
596
- "microM",
597
- "in",
598
- "mm"
599
- ],
600
- rpm: ["rpm", "Hz"],
601
- sdstats: ["CI", "Sigma"],
602
- specificHeatCapacity: [
603
- "J/(kg*degC)",
604
- "J/(kg*degK)",
605
- "BTU/(lbm*degF)"
606
- ],
607
- speed: [
608
- "km/h",
609
- "ft/min",
610
- "mph",
611
- "ft/h",
612
- "ft/s",
613
- "m/min",
614
- "m/s",
615
- "m/h"
616
- ],
617
- inverseStandSpeed: [
618
- "d/stand",
619
- "h/stand",
620
- "min/stand",
621
- "s/stand"
622
- ],
623
- rop: [
624
- "ft/h",
625
- "ft/min",
626
- "ft/s",
627
- "km/h",
628
- "m/h",
629
- "m/min",
630
- "m/s",
631
- "mph"
632
- ],
633
- stress: [
634
- "MPa",
635
- "kPa",
636
- "psi",
637
- "bar",
638
- "Pa",
639
- "ksi",
640
- "lbf/100ft2"
641
- ],
642
- temperature: [
643
- "C",
644
- "F",
645
- "K"
646
- ],
647
- pressurePerTemperature: [
648
- "Pa/C",
649
- "Bar/C",
650
- "psi/F",
651
- "psi/C"
652
- ],
653
- tempgrad: [
654
- "C/100m",
655
- "F/100ft",
656
- "K/100m",
657
- "C/m",
658
- "F/ft",
659
- "K/m"
660
- ],
661
- thermalConductivity: ["BTU/(h*ft*degF)", "W/(mK)"],
662
- thermalExpansionCoefficient: [
663
- "E-06/degC",
664
- "E-06/degF",
665
- "1/K"
666
- ],
667
- torque: [
668
- "Nm",
669
- "ftlbf",
670
- "kNm"
671
- ],
672
- torqueGradient: [
673
- "N",
674
- "lbf",
675
- "tonnes"
676
- ],
677
- turbulentSkin: [
678
- "s/m3",
679
- "1/m3/d",
680
- "1/MMSCFD"
681
- ],
682
- viscosity: [
683
- "Pa*s",
684
- "P",
685
- "mPa*s",
686
- "cP"
687
- ],
688
- inflowProductivityIndex: [
689
- "Sm3/d/bar",
690
- "STB/d/psi",
691
- "m3/s/bar"
692
- ],
693
- volume: [
694
- "m3",
695
- "bbl",
696
- "Mm3",
697
- "l",
698
- "USGal",
699
- "ft3",
700
- "STB",
701
- "Sm3",
702
- "MMSCF",
703
- "MSm3",
704
- "SCF"
705
- ],
706
- kickToleranceVolume: [
707
- "m3",
708
- "bbl",
709
- "USGal",
710
- "ft3",
711
- "STB",
712
- "Sm3",
713
- "SCF"
714
- ],
715
- weight: [
716
- "tonnes",
717
- "kg",
718
- "lbf",
719
- "mt",
720
- "kip",
721
- "N"
722
- ],
723
- weightGradient: ["ppf", "kg/m"],
724
- wgrad: ["sg", "ppg"],
725
- wltubulars: ["ppf", "kg/m"],
726
- youngsModulus: ["Pa", "psi"],
727
- massPerLength: ["kg/m", "lb/ft"],
728
- wearFactor: [
729
- "E-09/bar",
730
- "E-10/psi",
731
- "E-14/pa"
732
- ],
733
- volumeGradient: [
734
- "m3/m",
735
- "cm3/m",
736
- "mm3/m",
737
- "ft3/ft",
738
- "in3/ft"
739
- ],
740
- shearStress: ["Pa", "lbf/100ft2"],
741
- sensorAccelerometer: ["g", "m/s2"],
742
- sensorMagnetometer: ["nT", "Gs"],
743
- location: [
744
- "lk",
745
- "ftCla",
746
- "lkCla",
747
- "ftSe",
748
- "ydSe",
749
- "chSe",
750
- "chSe(T)",
751
- "ftGC",
752
- "ydInd",
753
- "ft",
754
- "m",
755
- "usft"
756
- ],
757
- mixingRequirements: ["m3/t", "L/100kg"],
758
- entalphy: [
759
- "J/kg",
760
- "kJ/kg",
761
- "BTU/lbm"
762
- ]
763
- });
764
- /**
765
- * Units list
766
- *
767
- * @readonly
768
- * @enum {Object}
769
- */
770
- const UNIT_FROM_KEY = Object.freeze({
771
- density: "sg",
772
- densityGas: "Gsg",
773
- densityOil: "sg",
774
- densityOilGas: "kg/m3",
775
- densitySolid: "kg/m3",
776
- length: "m",
777
- roughness: "m",
778
- speed: "m/s",
779
- diameters: "in",
780
- duration: "s",
781
- durationShort: "h",
782
- durationLong: "d",
783
- pressurechange: "bar",
784
- pressure: "bar",
785
- temperature: "C",
786
- tempgrad: "C/100m",
787
- volume: "m3",
788
- kickToleranceVolume: "m3",
789
- weight: "kg",
790
- force: "N",
791
- wgrad: "sg",
792
- wltubulars: "ppf",
793
- flowrate: "lpm",
794
- permeability: "mD",
795
- interfacialTension: "dyn/cm",
796
- deg: "deg",
797
- dls: "deg/30m",
798
- percentage: "%",
799
- latitude: "°N",
800
- longitude: "°E",
801
- torque: "Nm",
802
- rpm: "rpm",
803
- testSingleUnit: "m",
804
- turbulentSkin: "1/m3/d",
805
- pressurePerTemperature: "Pa/C",
806
- sdstats: "Sigma",
807
- acceleration: "m/s2",
808
- massFlowRate: "kg/s",
809
- angleGradient: "deg/m",
810
- viscosity: "Pa*s",
811
- weightGradient: "kg/m",
812
- intensity: "W/m2",
813
- gor: "Sm3/Sm3",
814
- inflowProductivityIndex: "Sm3/d/bar",
815
- wearFactor: "E-09/psi",
816
- location: "m",
817
- inverseStandSpeed: "s/stand",
818
- mixingRequirements: "m3/t",
819
- entalphy: "J/kg",
820
- shearStress: "Pa",
821
- volumeGradient: "m3/m",
822
- sensorAccelerometer: "g",
823
- sensorMagnetometer: "Gs",
824
- rotationalRate: "deg/h"
825
- });
826
- /**
827
- * Constants to help conversion
828
- *
829
- * @readonly
830
- * @enum {Object}
831
- */
832
- const C = Object.freeze({
833
- g: .0980665175317196,
834
- ft_to_m: .3048,
835
- inch_to_m: .0254,
836
- lbf_to_kg: .45359237,
837
- kg_to_lbf: 2.20462262184877,
838
- ppf_to_kgm: .45359237 / .3048,
839
- kg_cm3: .0293984025938081,
840
- bar_to_psi: 14.503773773022,
841
- bar_to_pascal: 1e5,
842
- sg_to_ppg: 8.345404265,
843
- bbl_to_m3: .158987294928,
844
- USGal_to_m3: .003785411784,
845
- kelvin_to_degrees: 273.15,
846
- tonnes_to_pascal: 9806.65,
847
- therm_exp_coeff: 1242e-8,
848
- psi_to_pascal: 6894.757293168361,
849
- ft3_to_m3: .028316846592,
850
- ft3_to_in3: 1728,
851
- day_to_second: 3600 * 24,
852
- m3_per_m_to_ft3_per_ft: 10.763910416709722,
853
- in3_per_ft_to_m3_per_m: 537633333333e-16,
854
- MSm3d_to_m3s: 625 / 54
855
- });
856
- /**
857
- * Conversions list
858
- *
859
- * All unit conversion formulas should have a credible source/reference (please add a comment with URL to where you
860
- * got the formula when adding new units to this package). For example:
861
- * - Wikipedia
862
- * - https://www.nist.gov/pml/special-publication-811/nist-guide-si-appendix-b-conversion-factors/nist-guide-si-appendix-b8
863
- * - https://www.wolframalpha.com/input?i=cubic+meter+to+bbl
864
- *
865
- * Do not round conversion factors in formulas (we need full precision). Make sure the inverse conversion (A->B->A)
866
- * produces a valid result.
867
- *
868
- * @readonly
869
- * @enum {Object}
870
- */
871
- const KNOWN_CONVERSIONS = Object.freeze({
872
- "m|mm": (val) => val * 1e3,
873
- "m|cm": (val) => val * 100,
874
- "m|km": (val) => val / 1e3,
875
- "m|ft": (val) => val / C.ft_to_m,
876
- "m|in": (val) => val / C.inch_to_m,
877
- "m|microM": (val) => val * 1e6,
878
- "mm|m": (val) => val / 1e3,
879
- "cm|m": (val) => val / 100,
880
- "km|m": (val) => val * 1e3,
881
- "ft|m": (val) => val * C.ft_to_m,
882
- "in|m": (val) => val * C.inch_to_m,
883
- "microM|m": (val) => val / 1e6,
884
- "m2|mm2": (val) => val * 1e6,
885
- "m2|cm2": (val) => val * 1e4,
886
- "m2|km2": (val) => val / 1e6,
887
- "m2|in2": (val) => val * 1550.0031,
888
- "m2|ft2": (val) => val * 10.76391,
889
- "m2|mile2": (val) => val * 3.861022e-7,
890
- "mm2|m2": (val) => val / 1e6,
891
- "cm2|m2": (val) => val / 1e4,
892
- "km2|m2": (val) => val * 1e6,
893
- "in2|m2": (val) => val / 1550.0031,
894
- "ft2|m2": (val) => val / 10.76391,
895
- "mile2|m2": (val) => val / 3.861022e-7,
896
- "m3|bbl": (val) => val / C.bbl_to_m3,
897
- "m3|ft3": (val) => val / C.ft3_to_m3,
898
- "m3|l": (val) => val * 1e3,
899
- "m3|Mm3": (val) => val / 1e6,
900
- "m3|USGal": (val) => val / C.USGal_to_m3,
901
- "bbl|m3": (val) => val * C.bbl_to_m3,
902
- "ft3|m3": (val) => val * C.ft3_to_m3,
903
- "Mm3|m3": (val) => val * 1e6,
904
- "l|m3": (val) => val / 1e3,
905
- "USGal|m3": (val) => val * C.USGal_to_m3,
906
- "m3|Sm3": (val) => val * 1,
907
- "m3|STB": (val) => val * 6.289512957422142,
908
- "Sm3|m3": (val) => val * 1,
909
- "STB|m3": (val) => val * .1589948230919721,
910
- "m3|MMSCF": (val) => val * 1e6 / C.ft3_to_m3,
911
- "m3|MSm3": (val) => val * 1e-6,
912
- "m3|SCF": (val) => val / C.ft3_to_m3,
913
- "MMSCF|m3": (val) => val * 1e-6 * C.ft3_to_m3,
914
- "MSm3|m3": (val) => val * 1e6,
915
- "SCF|m3": (val) => val * C.ft3_to_m3,
916
- "kg/m3|sg": (val) => val * .001,
917
- "kg/m3|g/cm3": (val) => val * .001,
918
- "kg/m3|lbm/ft3": (val) => val / 16.01846337,
919
- "kg/m3|lb/ft3": (val) => val / 16.01846337,
920
- "kg/m3|ppg": (val) => val * .008345404265,
921
- "sg|kg/m3": (val) => val * 1e3,
922
- "g/cm3|kg/m3": (val) => val * 1e3,
923
- "lbm/ft3|kg/m3": (val) => val * 16.01846337,
924
- "lb/ft3|kg/m3": (val) => val * 16.01846337,
925
- "ppg|kg/m3": (val) => val / .008345404265,
926
- "sg|kPa/m": (val) => val * 9.81,
927
- "kPa/m|sg": (val) => val / 9.81,
928
- "Gkg/m3|Gsg": (val) => val / 1.225,
929
- "Gkg/m3|Glbm/ft3": (val) => val / 16.0176516725,
930
- "Gkg/m3|Gppg": (val) => val / 119.8659491193,
931
- "Gsg|Gkg/m3": (val) => val * 1.225,
932
- "Glbm/ft3|Gkg/m3": (val) => val * 16.0176516725,
933
- "Gppg|Gkg/m3": (val) => val * 119.8659491193,
934
- "ppf|kg/m": (val) => val * .45359237 / .3048,
935
- "kg/m|ppf": (val) => val * 1 / (.45359237 / .3048),
936
- "kg/m|lbf/ft": (val) => val / .67196897675131,
937
- "lbf/ft|kg/m": (val) => val * .67196897675131,
938
- "Pa|psi": (val) => val / C.psi_to_pascal,
939
- "psi|Pa": (val) => val * C.psi_to_pascal,
940
- "Pa|bar": (val) => val * 1e-5,
941
- "Pa|kPa": (val) => val * .001,
942
- "Pa|MPa": (val) => val * 1e-6,
943
- "Pa|GPa": (val) => val * 1e-9,
944
- "bar|Pa": (val) => val * 1e5,
945
- "kPa|Pa": (val) => val * 1e3,
946
- "MPa|Pa": (val) => val * 1e6,
947
- "GPa|Pa": (val) => val * 1e9,
948
- "psi|ksi": (val) => val / 1e3,
949
- "ksi|psi": (val) => val * 1e3,
950
- "psi|lbf/100ft2": (val) => val * 14400,
951
- "lbf/100ft2|psi": (val) => val / 14400,
952
- "1/psi|1/Pa": (val) => val / C.psi_to_pascal,
953
- "1/bar|1/Pa": (val) => val * 1e-5,
954
- "1/kPa|1/Pa": (val) => val * .001,
955
- "1/MPa|1/Pa": (val) => val * 1e-6,
956
- "1/GPa|1/Pa": (val) => val * 1e-9,
957
- "1/Pa|1/psi": (val) => val * C.psi_to_pascal,
958
- "1/Pa|1/bar": (val) => val * 1e5,
959
- "1/Pa|1/kPa": (val) => val * 1e3,
960
- "1/Pa|1/MPa": (val) => val * 1e6,
961
- "1/Pa|1/GPa": (val) => val * 1e9,
962
- "C|F": (val) => val * 1.8 + 32,
963
- "F|C": (val) => (val - 32) * 5 / 9,
964
- "K|C": (val) => val - C.kelvin_to_degrees,
965
- "C|K": (val) => val + C.kelvin_to_degrees,
966
- "C/100m|F/100ft": (val) => val * 1.8 * C.ft_to_m,
967
- "F/100ft|C/100m": (val) => val * 5 / 9 / C.ft_to_m,
968
- "C/100m|C/m": (val) => val / 100,
969
- "C/m|C/100m": (val) => val * 100,
970
- "C/100m|F/ft": (val) => val * 1.8 / 100 * C.ft_to_m,
971
- "F/ft|C/100m": (val) => val * 5 / 9 * 100 / C.ft_to_m,
972
- "C/100m|K/m": (val) => val / 100,
973
- "K/m|C/100m": (val) => val * 100,
974
- "K/100m|C/100m": (val) => val,
975
- "C/100m|K/100m": (val) => val,
976
- "Pa/C|Bar/C": (val) => val * 1e-5,
977
- "Pa/C|psi/F": (val) => val / 1.8 / C.psi_to_pascal,
978
- "Pa/C|psi/C": (val) => val / C.psi_to_pascal,
979
- "Bar/C|Pa/C": (val) => val * 1e5,
980
- "psi/F|Pa/C": (val) => val * 1.8 * C.psi_to_pascal,
981
- "psi/C|Pa/C": (val) => val * C.psi_to_pascal,
982
- "psi/F|psi/C": (val) => val * 1.8,
983
- "psi/C|psi/F": (val) => val / 1.8,
984
- "kg|kgf": (val) => val,
985
- "kg|lbf": (val) => val * C.kg_to_lbf,
986
- "kg|t": (val) => val / 1e3,
987
- "kg|tonnes": (val) => val / 1e3,
988
- "kg|mt": (val) => val / 1e3,
989
- "kg|kip": (val) => val * C.kg_to_lbf * .001,
990
- "kgf|kg": (val) => val,
991
- "lbf|kg": (val) => val * C.lbf_to_kg,
992
- "t|kg": (val) => val * 1e3,
993
- "tonnes|kg": (val) => val * 1e3,
994
- "mt|kg": (val) => val * 1e3,
995
- "kip|kg": (val) => val * 1e3 * C.lbf_to_kg,
996
- "tonnes|lbf": (val) => val * 1e3 * C.kg_to_lbf,
997
- "lbf|tonnes": (val) => val * C.lbf_to_kg / 1e3,
998
- "t|lbf": (val) => val * 1e3 * C.kg_to_lbf,
999
- "lbf|t": (val) => val * C.lbf_to_kg / 1e3,
1000
- "mt|lbf": (val) => val * 1e3 * C.kg_to_lbf,
1001
- "lbf|mt": (val) => val / (1e3 * C.kg_to_lbf),
1002
- "kgf|lbf": (val) => val * C.kg_to_lbf,
1003
- "lbf|kgf": (val) => val * C.lbf_to_kg,
1004
- "kg|g": (val) => val * 1e3,
1005
- "g|kg": (val) => val / 1e3,
1006
- "kgf|t": (val) => val / 1e3,
1007
- "t|kgf": (val) => val * 1e3,
1008
- "kgf|tonnes": (val) => val / 1e3,
1009
- "tonnes|kgf": (val) => val * 1e3,
1010
- "kg/m|lb/ft": (val) => val * 1.4881639435695537,
1011
- "lb/ft|kg/m": (val) => val * .6719689751395069,
1012
- "kg|N": (val) => val * C.g * 100,
1013
- "N|kg": (val) => val / (C.g * 100),
1014
- "m/s|km/h": (val) => val * 3.6,
1015
- "km/h|m/s": (val) => val / 3.6,
1016
- "m/s|ft/s": (val) => val / C.ft_to_m,
1017
- "m/s|ft/min": (val) => val * 60 / C.ft_to_m,
1018
- "m/s|ft/h": (val) => val * 3600 / C.ft_to_m,
1019
- "m/s|m/min": (val) => val * 60,
1020
- "m/s|m/h": (val) => val * 3600,
1021
- "ft/s|m/s": (val) => val * C.ft_to_m,
1022
- "ft/min|m/s": (val) => val * C.ft_to_m / 60,
1023
- "ft/h|m/s": (val) => val * C.ft_to_m / 3600,
1024
- "m/min|m/s": (val) => val / 60,
1025
- "m/h|m/s": (val) => val / 3600,
1026
- "m/s|mph": (val) => val * 2.2369362920544,
1027
- "mph|m/s": (val) => val / 2.2369362920544,
1028
- "ft/h|ft/d": (val) => val * 24,
1029
- "ft/d|ft/h": (val) => val / 24,
1030
- "ft/h|m/h": (val) => val * C.ft_to_m,
1031
- "m/h|ft/h": (val) => val / C.ft_to_m,
1032
- "ft/d|m/h": (val) => val * C.ft_to_m / 24,
1033
- "m/h|ft/d": (val) => val * 24 / C.ft_to_m,
1034
- "ft/d|m/d": (val) => val * C.ft_to_m,
1035
- "m/d|ft/d": (val) => val / C.ft_to_m,
1036
- "m/h|m/d": (val) => val * 24,
1037
- "m/d|m/h": (val) => val / 24,
1038
- "l/m|bbl/ft": (val) => val * .0019171343228277056,
1039
- "bbl/ft|l/m": (val) => val / .0019171343228277056,
1040
- "m3/s|ft3/s": (val) => val / C.ft3_to_m3,
1041
- "m3/s|lpm": (val) => val * 6e4,
1042
- "m3/s|bpm": (val) => val * 377.388646,
1043
- "m3/s|m3/min": (val) => val * 60,
1044
- "m3/s|m3/d": (val) => val * C.day_to_second,
1045
- "m3/s|bbl/d": (val) => val * 543439.6505653338,
1046
- "m3/s|ft3/d": (val) => val * C.day_to_second / C.ft3_to_m3,
1047
- "m3/s|gpm": (val) => val * 25e11 / 157725491,
1048
- "m3/s|MMSCFD": (val) => val / .32774128,
1049
- "m3/s|STB/d": (val) => val * 0x7a7f6097db00 / 247854343,
1050
- "m3/s|Sm3/d": (val) => val * C.day_to_second,
1051
- "m3/s|Sm3/min": (val) => val * 60,
1052
- "Sm3/min|m3/s": (val) => val / 60,
1053
- "m3/s|MSm3/d": (val) => val / C.MSm3d_to_m3s,
1054
- "m3/s|SCF/d": (val) => val * 3051187.2047366146,
1055
- "ft3/s|m3/s": (val) => val * C.ft3_to_m3,
1056
- "lpm|m3/s": (val) => val / 6e4,
1057
- "lps|lpm": (val) => val * 60,
1058
- "lpm|lps": (val) => val / 60,
1059
- "bpm|m3/s": (val) => val / 377.388646,
1060
- "m3/d|m3/s": (val) => val / C.day_to_second,
1061
- "m3/min|m3/s": (val) => val / 60,
1062
- "bbl/d|m3/s": (val) => val / C.day_to_second * C.bbl_to_m3,
1063
- "ft3/d|m3/s": (val) => val / C.day_to_second * C.ft3_to_m3,
1064
- "ft3/d|m3/d": (val) => val * C.ft3_to_m3,
1065
- "m3/d|ft3/d": (val) => val / C.ft3_to_m3,
1066
- "m3/d|ft3/s": (val) => val / C.ft3_to_m3 / C.day_to_second,
1067
- "gpm|m3/s": (val) => val * 157725491 / 25e11,
1068
- "MMSCFD|m3/s": (val) => val * .32774128,
1069
- "Mm3/d|m3/d": (val) => val * 1e6,
1070
- "m3/d|Mm3/d": (val) => val * 1e-6,
1071
- "STB/d|m3/s": (val) => val * 184021785986e-17,
1072
- "Sm3/d|m3/d": (val) => val,
1073
- "m3/d|Sm3/d": (val) => val,
1074
- "Sm3/d|m3/s": (val) => val / C.day_to_second,
1075
- "MSm3/d|Sm3/d": (val) => val * 1e6,
1076
- "Sm3/d|MSm3/d": (val) => val * 1e-6,
1077
- "MSm3/d|m3/s": (val) => val * C.MSm3d_to_m3s,
1078
- "SCF/d|m3/s": (val) => val * 3.2774128e-7,
1079
- "1/m3/d|1/MMSCFD": (val) => val * 28316.85,
1080
- "1/MMSCFD|1/m3/d": (val) => val / 28316.85,
1081
- "s/m3|1/m3/d": (val) => val / 86400,
1082
- "1/m3/d|s/m3": (val) => val * 86400,
1083
- "kg/s|lbm/s": (val) => val * 2.20462262,
1084
- "lbm/s|kg/s": (val) => val / 2.20462262,
1085
- "kg/s|tonnes/h": (val) => val * 3.6,
1086
- "tonnes/h|kg/s": (val) => val / 3.6,
1087
- "kg/s|tons/h": (val) => val * 3.9683207193277967,
1088
- "tons/h|kg/s": (val) => val * .2519957611111111,
1089
- "lbm/s|tonnes/h": (val) => val * 1.632932532,
1090
- "tonnes/h|lbm/s": (val) => val * .612395172735771,
1091
- "lbm/s|tons/h": (val) => val * 1.8,
1092
- "tons/h|lbm/s": (val) => val / 1.8,
1093
- "tonnes/h|tons/h": (val) => val * 1.1023113109243878,
1094
- "tons/h|tonnes/h": (val) => val * .90718474,
1095
- "mD|m2": (val) => val * 9869233e-19,
1096
- "m2|mD": (val) => val / 9869233e-19,
1097
- "N/m|lbf/ft": (val) => val * .22480894387096 * C.ft_to_m,
1098
- "lbf/ft|N/m": (val) => val / .22480894387096 / C.ft_to_m,
1099
- "dyn/cm|mN/m": (val) => val,
1100
- "mN/m|dyn/cm": (val) => val,
1101
- "dyn/cm|N/m": (val) => val * .001,
1102
- "N/m|dyn/cm": (val) => val * 1e3,
1103
- "mN/m|N/m": (val) => val * .001,
1104
- "N/m|mN/m": (val) => val * 1e3,
1105
- "Nm|ftlbf": (val) => val * .737562058700684,
1106
- "Nm|kNm": (val) => val / 1e3,
1107
- "kNm|Nm": (val) => val * 1e3,
1108
- "ftlbf|Nm": (val) => val / .737562058700684,
1109
- "N|kN": (val) => val * .001,
1110
- "N|kgf": (val) => val * 2e4 / 196133,
1111
- "N|lbf": (val) => val * 2e12 / 8896443230521,
1112
- "kN|lbf": (val) => val * 1e3 * 2e12 / 8896443230521,
1113
- "N|tonneForce": (val) => val * 20 / 196133,
1114
- "kN|N": (val) => val / .001,
1115
- "kgf|N": (val) => val * 196133 / 2e4,
1116
- "lbf|N": (val) => val * 8896443230521 / 2e12,
1117
- "lbf|kN": (val) => val * 8896443230521 / (2e12 * 1e3),
1118
- "lbf|tonneForce": (val) => val * 45359237 / 1e11,
1119
- "klbf|tonneForce": (val) => val * 45359237 / (1e11 * .001),
1120
- "tonneForce|N": (val) => val * 196133 / 20,
1121
- "tonneForce|lbf": (val) => val * 1e11 / 45359237,
1122
- "tonneForce|klbf": (val) => val * 1e11 / (45359237 * 1e3),
1123
- "klbf|lbf": (val) => val * 1e3,
1124
- "lbf|klbf": (val) => val / 1e3,
1125
- "s|min": (val) => val / 60,
1126
- "s|h": (val) => val / 3600,
1127
- "s|d": (val) => val / (24 * 3600),
1128
- "min|s": (val) => val * 60,
1129
- "h|s": (val) => val * 3600,
1130
- "d|s": (val) => val * 24 * 3600,
1131
- "year|d": (val) => val * 365.25,
1132
- "d|year": (val) => val / 365.25,
1133
- "year|month": (val) => val * 12,
1134
- "month|year": (val) => val / 12,
1135
- "month|d": (val) => val * 30.4375,
1136
- "d|month": (val) => val / 30.4375,
1137
- "s/stand|min/stand": (val) => val / 60,
1138
- "s/stand|h/stand": (val) => val / 3600,
1139
- "s/stand|d/stand": (val) => val / 86400,
1140
- "min/stand|s/stand": (val) => val * 60,
1141
- "h/stand|s/stand": (val) => val * 3600,
1142
- "d/stand|s/stand": (val) => val * 86400,
1143
- "min/stand|h/stand": (val) => val / 60,
1144
- "min/stand|d/stand": (val) => val / 1440,
1145
- "h/stand|min/stand": (val) => val * 60,
1146
- "h/stand|d/stand": (val) => val / 24,
1147
- "d/stand|min/stand": (val) => val * 1440,
1148
- "d/stand|h/stand": (val) => val * 24,
1149
- "%|fr": (val) => val * .01,
1150
- "fr|%": (val) => val / .01,
1151
- "deg|rad": (val) => val * Math.PI / 180,
1152
- "rad|deg": (val) => val * 180 / Math.PI,
1153
- "W|hp": (val) => val / 745.699872,
1154
- "hp|W": (val) => val * 745.699872,
1155
- "W|kW": (val) => val / 1e3,
1156
- "W|MW": (val) => val / 1e6,
1157
- "kW|W": (val) => val * 1e3,
1158
- "MW|W": (val) => val * 1e6,
1159
- "W|BTU/h": (val) => val * 3.4121416351331,
1160
- "BTU/h|W": (val) => val / 3.4121416351331,
1161
- "hhp|hp": (val) => val,
1162
- "hp|hhp": (val) => val,
1163
- "°N|°S": (val) => val,
1164
- "°S|°N": (val) => val,
1165
- "°W|°E": (val) => val,
1166
- "°E|°W": (val) => val,
1167
- "BTU/(Kg*K)|BTU/(lbm*degF)": (val) => val / 4186.798188,
1168
- "BTU/(lbm*degF)|J/(kg*degC)": (val) => val * 4186.798188,
1169
- "BTU/(lbm*degF)|BTU/(Kg*K)": (val) => val * 4186.798188,
1170
- "J/(kg*degK)|J/(kg*degC)": (val) => val,
1171
- "J/(kg*degC)|BTU/(lbm*degF)": (val) => val / 4186.798188,
1172
- "J/(kg*degC)|J/(kg*degK)": (val) => val,
1173
- "J/(kg*degC)|J/(s*m*degK)": (val) => val,
1174
- "BTU/(h*ft*degF)|W/(mK)": (val) => val * 1.7295772056,
1175
- "BTU/(h*ft*degF)|J/(s*m*degK)": (val) => val * 1.7295772056,
1176
- "W/(mK)|BTU/(h*ft*degF)": (val) => val / 1.7295772056,
1177
- "W/(mK)|J/(s*m*degK)": (val) => val,
1178
- "W/(m*degK)|J/(s*m*degK)": (val) => val,
1179
- "W/(m*degK)|BTU/(h*ft*degF)": (val) => val / 1.7295772056,
1180
- "J/(s*m*degK)|BTU/(h*ft*degF)": (val) => val / 1.7295772056,
1181
- "J/(s*m*degK)|W/(m*degK)": (val) => val,
1182
- "J/(s*m*degK)|W/(mK)": (val) => val,
1183
- "J/(s*m*degK)|J/(kg*degC)": (val) => val,
1184
- "E-06/degF|E-06/degC": (val) => val * 1.8,
1185
- "E-06/degC|E-06/degF": (val) => val / 1.8,
1186
- "E-06/degC|1/K": (val) => val / 1e6,
1187
- "1/K|E-06/degC": (val) => val * 1e6,
1188
- "rpm|Hz": (val) => val / 60,
1189
- "Hz|rpm": (val) => val * 60,
1190
- "CI|Sigma": (val) => get_k_from_conf_int(val),
1191
- "Sigma|CI": (val) => get_conf_int_from_k(val),
1192
- "g/mol|kg/mol": (val) => val / 1e3,
1193
- "kg/mol|g/mol": (val) => val * 1e3,
1194
- "lbf/mol|kg/mol": (val) => val / C.kg_to_lbf,
1195
- "kg/mol|lbf/mol": (val) => val * C.kg_to_lbf,
1196
- "m/s2|ft/s2": (val) => val / C.ft_to_m,
1197
- "ft/s2|m/s2": (val) => val * C.ft_to_m,
1198
- "Pa*s|P": (val) => val * 10,
1199
- "P|Pa*s": (val) => val / 10,
1200
- "mPa*s|Pa*s": (val) => val / 1e3,
1201
- "Pa*s|mPa*s": (val) => val * 1e3,
1202
- "cP|Pa*s": (val) => val * .001,
1203
- "Pa*s|cP": (val) => val / .001,
1204
- "Pa/m|bar/m": (val) => val * 1e-5,
1205
- "bar/m|Pa/m": (val) => val * 1e5,
1206
- "Pa/m|kPa/m": (val) => val / 1e3,
1207
- "kPa/m|Pa/m": (val) => val * 1e3,
1208
- "Pa/m|bar/100m": (val) => val * .001,
1209
- "bar/100m|Pa/m": (val) => val * 1e3,
1210
- "bar/m|bar/100m": (val) => val * 100,
1211
- "bar/100m|bar/m": (val) => val / 100,
1212
- "psi/ft|Pa/m": (val) => val * C.psi_to_pascal / C.ft_to_m,
1213
- "Pa/m|psi/ft": (val) => val / C.psi_to_pascal * C.ft_to_m,
1214
- "psi/100ft|Pa/m": (val) => val * 68.9475729 / C.ft_to_m,
1215
- "Pa/m|psi/100ft": (val) => val / 68.9475729 * C.ft_to_m,
1216
- "deg/30m|deg/100ft": (val) => val * (100 * C.ft_to_m / 30),
1217
- "deg/100ft|deg/30m": (val) => val / (100 * C.ft_to_m / 30),
1218
- "deg/30m|deg/m": (val) => val / 30,
1219
- "deg/m|deg/30m": (val) => val * 30,
1220
- "deg/100ft|deg/ft": (val) => val / 100,
1221
- "deg/ft|deg/100ft": (val) => val * 100,
1222
- "deg/100ft|deg/m": (val) => val / (100 * C.ft_to_m),
1223
- "deg/m|deg/100ft": (val) => val * (100 * C.ft_to_m),
1224
- "deg/ft|deg/m": (val) => val / C.ft_to_m,
1225
- "deg/m|deg/ft": (val) => val * C.ft_to_m,
1226
- "deg/m|rad/m": (val) => val * Math.PI / 180,
1227
- "rad/m|deg/m": (val) => val * 180 / Math.PI,
1228
- "rad/ft|deg/m": (val) => val * 180 / Math.PI / C.ft_to_m,
1229
- "deg/m|rad/ft": (val) => val * Math.PI / 180 * C.ft_to_m,
1230
- "deg/10m|deg/100ft": (val) => val * (10 * C.ft_to_m),
1231
- "deg/100ft|deg/10m": (val) => val / (10 * C.ft_to_m),
1232
- "deg/10m|deg/m": (val) => val / 10,
1233
- "deg/m|deg/10m": (val) => val * 10,
1234
- "deg/30m|deg/10m": (val) => val / 3,
1235
- "deg/10m|deg/30m": (val) => val * 3,
1236
- "deg/10m|rad/m": (val) => val * Math.PI / 180 / 10,
1237
- "rad/m|deg/10m": (val) => val * 180 / Math.PI * 10,
1238
- "W/m2|hhp/in2": (val) => val * (1 / 745.699872 / 1550.0031),
1239
- "W/m2|hhp/ft2": (val) => val * (1 / 745.699872 / 10.76391),
1240
- "hhp/in2|W/m2": (val) => val / (1 / 745.699872 / 1550.0031),
1241
- "hhp/ft2|W/m2": (val) => val / (1 / 745.699872 / 10.76391),
1242
- "SCF/STB|Sm3/Sm3": (val) => val * .178099173553719,
1243
- "Sm3/Sm3|SCF/STB": (val) => val * 5.614849187935035,
1244
- "Sm3/d/bar|m3/s/bar": (val) => val / 86400,
1245
- "STB/d/psi|m3/s/bar": (val) => val / 37468.77736,
1246
- "m3/s/bar|Sm3/d/bar": (val) => val * 86400,
1247
- "m3/s/bar|STB/d/psi": (val) => val * 37468.77736,
1248
- "E-10/psi|E-09/bar": (val) => val * 1.450377378,
1249
- "E-10/psi|E-14/pa": (val) => val * 1.450377378,
1250
- "E-14/pa|E-10/psi": (val) => val / 1.450377378,
1251
- "E-09/bar|E-10/psi": (val) => val / 1.450377378,
1252
- "E-14/pa|1/Pa": (val) => val / Math.pow(10, 14),
1253
- "E-09/bar|1/bar": (val) => val / Math.pow(10, 9),
1254
- "E-10/psi|1/psi": (val) => val / Math.pow(10, 10),
1255
- "1/Pa|E-14/pa": (val) => val * Math.pow(10, 14),
1256
- "1/bar|E-09/bar": (val) => val * Math.pow(10, 9),
1257
- "1/psi|E-10/psi": (val) => val * Math.pow(10, 10),
1258
- "m3/m|cm3/m": (val) => val * 10 ** 6,
1259
- "m3/m|mm3/m": (val) => val * 10 ** 9,
1260
- "m3/m|ft3/ft": (val) => val * C.m3_per_m_to_ft3_per_ft,
1261
- "m3/m|in3/ft": (val) => val * C.m3_per_m_to_ft3_per_ft * C.ft3_to_in3,
1262
- "cm3/m|m3/m": (val) => val * 1e-6,
1263
- "cm3/m|mm3/m": (val) => val * 1e3,
1264
- "cm3/m|ft3/ft": (val) => val * C.m3_per_m_to_ft3_per_ft * 1e-6,
1265
- "cm3/m|in3/ft": (val) => val * C.m3_per_m_to_ft3_per_ft * 1e-6 * C.ft3_to_in3,
1266
- "mm3/m|m3/m": (val) => val * 1e-9,
1267
- "mm3/m|cm3/m": (val) => val * .001,
1268
- "mm3/m|ft3/ft": (val) => val * C.m3_per_m_to_ft3_per_ft * 1e-9,
1269
- "mm3/m|in3/ft": (val) => val * C.m3_per_m_to_ft3_per_ft * 1e-9 * C.ft3_to_in3,
1270
- "ft3/ft|m3/m": (val) => val * .09290304,
1271
- "ft3/ft|cm3/m": (val) => val * 92903.04,
1272
- "ft3/ft|mm3/m": (val) => val * 92903040,
1273
- "ft3/ft|in3/ft": (val) => val * 1728,
1274
- "in3/ft|m3/m": (val) => val * C.in3_per_ft_to_m3_per_m,
1275
- "in3/ft|cm3/m": (val) => val * C.in3_per_ft_to_m3_per_m * 1e6,
1276
- "in3/ft|mm3/m": (val) => val * C.in3_per_ft_to_m3_per_m * 1e9,
1277
- "in3/ft|ft3/ft": (val) => val / C.ft3_to_in3,
1278
- "Pa|lbf/100ft2": (val) => val * 2.088543423315013,
1279
- "lbf/100ft2|Pa": (val) => val * .4788025898033584,
1280
- "usft|m": (val) => val * .30480060960121924,
1281
- "lk|m": (val) => val * .201168,
1282
- "ftCla|m": (val) => val * .3047972651151,
1283
- "lkCla|m": (val) => val * .2011057269733667,
1284
- "ftGC|m": (val) => val * .30479971018150875,
1285
- "ydInd|m": (val) => val * .9143985307444408,
1286
- "ftSe|m": (val) => val * (12 / 39.370147),
1287
- "ydSe|m": (val) => val * .9143991154275526,
1288
- "chSe|m": (val) => val * 20.11676512155263,
1289
- "chSe(T)|m": (val) => val * 20.116756,
1290
- "m|usft": (val) => val / .30480060960121924,
1291
- "m|lk": (val) => val / .201168,
1292
- "m|ftCla": (val) => val / .3047972651151,
1293
- "m|lkCla": (val) => val / .2011057269733667,
1294
- "m|ftGC": (val) => val / .30479971018150875,
1295
- "m|ydInd": (val) => val / .9143985307444408,
1296
- "m|ftSe": (val) => val / (12 / 39.370147),
1297
- "m|ydSe": (val) => val / .9143991154275526,
1298
- "m|chSe": (val) => val / 20.11676512155263,
1299
- "m|chSe(T)": (val) => val / 20.116756,
1300
- "m3/t|L/100kg": (val) => val * 100,
1301
- "L/100kg|m3/t": (val) => val * .01,
1302
- "kJ/kg|J/kg": (val) => val * 1e3,
1303
- "J/kg|kJ/kg": (val) => val / 1e3,
1304
- "BTU/lbm|J/kg": (val) => val * 2326,
1305
- "J/kg|BTU/lbm": (val) => val / 2326,
1306
- "g|m/s2": (val) => val * 9.81,
1307
- "m/s2|g": (val) => val / 9.81,
1308
- "Gs|nT": (val) => val * 1e5,
1309
- "nT|Gs": (val) => val / 1e5
1310
- });
1311
- /**
1312
- * Deprecated units
1313
- *
1314
- * @readonly
1315
- * @enum {Object}
1316
- */
1317
- const DEPRECATED_UNITS = Object.freeze({
1318
- "N-m": "Nm",
1319
- "ft-lbf": "ftlbf",
1320
- "BTU/hr": "BTU/h",
1321
- "BTU/(htf*degF)": "BTU/(h*ft*degF)",
1322
- "BTU/(hft*degF)": "BTU/(h*ft*degF)"
1323
- });
1324
- /**
1325
- * This list is mapping from legal alternative unit names to our selected unit name
1326
- *
1327
- * @readonly
1328
- * @enum {Object}
1329
- */
1330
- const UNIT_ALIASES = Object.freeze({
1331
- "lbs/ft": "lb/ft",
1332
- "lbm/ft": "lb/ft",
1333
- ftUS: "usft"
1334
- });
1335
- /**
1336
- * Intermediate conversions
1337
- *
1338
- * @readonly
1339
- * @enum {Object}
1340
- */
1341
- const INTERMEDIATE_CONVERSIONS = Object.freeze({
1342
- mm: "m",
1343
- cm: "m",
1344
- km: "m",
1345
- ft: "m",
1346
- in: "m",
1347
- microM: "m",
1348
- lbf: "kg",
1349
- t: "kg",
1350
- tonnes: "kg",
1351
- mt: "kg",
1352
- kip: "kg",
1353
- kW: "W",
1354
- MW: "W",
1355
- hp: "W",
1356
- hhp: "hp",
1357
- mm2: "m2",
1358
- cm2: "m2",
1359
- km2: "m2",
1360
- in2: "m2",
1361
- ft2: "m2",
1362
- mile2: "m2",
1363
- bbl: "m3",
1364
- ft3: "m3",
1365
- Mm3: "m3",
1366
- l: "m3",
1367
- USGal: "m3",
1368
- Sm3: "m3",
1369
- STB: "m3",
1370
- MMSCF: "m3",
1371
- MSm3: "m3",
1372
- SCF: "m3",
1373
- kN: "N",
1374
- kgf: "N",
1375
- tonneForce: "N",
1376
- klbf: "lbf",
1377
- psi: "Pa",
1378
- bar: "Pa",
1379
- kPa: "Pa",
1380
- MPa: "Pa",
1381
- ksi: "psi",
1382
- "lbf/100ft2": "psi",
1383
- "psi/100ft": "Pa/m",
1384
- "psi/ft": "Pa/m",
1385
- "bar/100m": "Pa/m",
1386
- "bar/m": "Pa/m",
1387
- "Pa/m": "kPa/m",
1388
- sg: "kg/m3",
1389
- "g/cm3": "kg/m3",
1390
- "lbm/ft3": "kg/m3",
1391
- "lb/ft3": "kg/m3",
1392
- ppg: "kg/m3",
1393
- "kPa/m": "sg",
1394
- Gsg: "Gkg/m3",
1395
- Gppg: "Gkg/m3",
1396
- "Glbm/ft3": "Gkg/m3",
1397
- "1/psi": "1/Pa",
1398
- "1/bar": "1/Pa",
1399
- "1/kPa": "1/Pa",
1400
- "1/MPa": "1/Pa",
1401
- "1/GPa": "1/Pa",
1402
- "ft/s": "m/s",
1403
- "ft/min": "m/s",
1404
- "ft/h": "m/s",
1405
- "m/min": "m/s",
1406
- "m/h": "m/s",
1407
- mph: "m/s",
1408
- "ft3/s": "m3/s",
1409
- lpm: "m3/s",
1410
- lps: "lpm",
1411
- bpm: "m3/s",
1412
- "m3/d": "m3/s",
1413
- "bbl/d": "m3/s",
1414
- "ft3/d": "m3/s",
1415
- "STB/d": "m3/s",
1416
- "Sm3/d": "m3/s",
1417
- "Sm3/min": "m3/s",
1418
- gpm: "m3/s",
1419
- MMSCFD: "m3/s",
1420
- "Mm3/d": "m3/d",
1421
- "m3/min": "m3/s",
1422
- "MSm3/d": "m3/s",
1423
- "lbf/ft": "N/m",
1424
- min: "s",
1425
- h: "s",
1426
- d: "s",
1427
- month: "d",
1428
- year: "d",
1429
- "J/(kg*degK)": "J/(kg*degC)",
1430
- "BTU/(lbm*degF)": "J/(kg*degC)",
1431
- "BTU/(Kg*K)": "J/(kg*degC)",
1432
- "BTU/(h*ft*degF)": "J/(s*m*degK)",
1433
- "W/(m*degK)": "J/(s*m*degK)",
1434
- "W/(mK)": "J/(s*m*degK)",
1435
- K: "C",
1436
- "C/m": "C/100m",
1437
- "F/ft": "C/100m",
1438
- "K/m": "C/100m",
1439
- "F/100ft": "C/100m",
1440
- "K/100m": "C/100m",
1441
- "Bar/C": "Pa/C",
1442
- "s/m3": "1/m3/d",
1443
- "1/MMSCFD": "1/m3/d",
1444
- P: "Pa*s",
1445
- "mPa*s": "Pa*s",
1446
- cP: "Pa*s",
1447
- "hhp/in2": "W/m2",
1448
- "hhp/ft2": "W/m2",
1449
- "Sm3/d/bar": "m3/s/bar",
1450
- "STB/d/psi": "m3/s/bar",
1451
- "deg/100ft": "deg/m",
1452
- "deg/30m": "deg/m",
1453
- "deg/10m": "deg/m",
1454
- "deg/ft": "deg/m",
1455
- "rad/ft": "deg/m",
1456
- "lbf/mol": "kg/mol",
1457
- "g/mol": "kg/mol",
1458
- "1/K": "E-06/degC",
1459
- "E-09/bar": "E-10/psi",
1460
- "E-14/pa": "E-10/psi",
1461
- "1/Pa": "E-14/pa",
1462
- kNm: "Nm",
1463
- ftlbf: "Nm",
1464
- lk: "m",
1465
- ftCla: "m",
1466
- lkCla: "m",
1467
- ftSe: "m",
1468
- ydSe: "m",
1469
- chSe: "m",
1470
- "chSe(T)": "m",
1471
- ftGC: "m",
1472
- ydInd: "m",
1473
- "BTU/lbm": "J/kg"
1474
- });
1475
- /**
1476
- * List of all known units in application
1477
- *
1478
- * @readonly
1479
- * @enum {string[]}
1480
- */
1481
- const KNOWN_UNITS = Object.freeze(Array.from(new Set(Object.values(ALT_UNITS).flat())));
1482
- const SPECIAL_NUMBERS_STRING = [
1483
- NaN,
1484
- -Infinity,
1485
- Infinity
1486
- ].map((number) => number.toString());
1487
- /**
1488
- * Description for the different quantites
1489
- * @readonly
1490
- */
1491
- const QUANTITIES_DESCRIPTION = {
1492
- density: "Density",
1493
- length: "Length",
1494
- duration: "Duration",
1495
- temperature: "Temperature",
1496
- tempgrad: "Temperature Gradient",
1497
- volume: "Volume",
1498
- weight: "Weight",
1499
- angles: "Angles",
1500
- depth: "Depth",
1501
- distance: "Distances",
1502
- height: "Height",
1503
- diameters: "Diameters",
1504
- doglegSeverity: "Dogleg severity",
1505
- fluidCompressibility: "Fluid Compressibility",
1506
- force: "Force",
1507
- gasVolume: "Gas volume",
1508
- oilVolume: "Oil volume",
1509
- moleWeight: "Mole weight",
1510
- linearCapacity: "Linear Capacity",
1511
- stress: "Stress",
1512
- thermalConductivity: "Thermal conductivity",
1513
- specificHeatCapacity: "Specific heat capacity",
1514
- thermalExpansionCoefficient: "Thermal expansion coefficient",
1515
- youngsModulus: "Youngs Modulus",
1516
- torque: "Torque",
1517
- areaOther: "Area - Other",
1518
- areaTubular: "Area - Tubular",
1519
- pumpRate: "Pump Rate",
1520
- pressure: "Pressure",
1521
- blowoutFlowRate: "Flowrate (blowout)",
1522
- percentage: "Percentage",
1523
- frequency: "Frequency",
1524
- torqueGradient: "Torque gradient",
1525
- pressureGradient: "Pressure gradient",
1526
- flowrate: "Volumetric flow rate",
1527
- massFlowRate: "Mass flow rate",
1528
- angleGradient: "Angle gradient",
1529
- weightGradient: "Weight gradient",
1530
- forceGradient: "Force gradient",
1531
- interfacialTension: "Interfacial tension",
1532
- acceleration: "Acceleration",
1533
- viscosity: "Viscosity",
1534
- power: "Power",
1535
- intensity: "Power intensity",
1536
- gasliftFlowRate: "Flowrate (Gas lift)",
1537
- productionFlowRate: "Flowrate (production)",
1538
- productionFlowRateOil: "Flowrate for Oil (production)",
1539
- productionFlowRateGas: "Flowrate for Gas (production)",
1540
- injectionFlowRate: "Flowrate (injection)",
1541
- blowoutOilFlowRate: "Flowrate for Oil (blowout)",
1542
- blowoutGasFlowRate: "Flowrate for Gas (blowout)",
1543
- gor: "Gas Oil Ratio",
1544
- rotationalSpeed: "Rotational Speed",
1545
- densityGas: "Density for gas",
1546
- inflowProductivityIndex: "Inflow productivity index",
1547
- latitude: "Latitude",
1548
- longitude: "Longitude",
1549
- permeability: "Permeability",
1550
- sdstats: "Standard deviation",
1551
- roughness: "Material Roughness",
1552
- wltubulars: "Tubular weight",
1553
- speed: "Velocity",
1554
- inverseStandSpeed: "Inverse Stand velocity",
1555
- rop: "Rate of Penetration (ROP)",
1556
- densityOil: "Density for oil",
1557
- densityOilGas: "Density for oil/gas",
1558
- kickToleranceVolume: "Volume for kick tolerance",
1559
- densitySolid: "Density for solid",
1560
- massPerLength: "Mass Per Length",
1561
- durationShort: "Duration (TempSim short)",
1562
- durationLong: "Duration (TempSim long)",
1563
- wearFactor: "Wear factor",
1564
- turbulentSkin: "Turbulent skin",
1565
- pressurePerTemperature: "Pressure per temperature",
1566
- location: "Location coordinates length",
1567
- mixingRequirements: "Ratio between water and cement",
1568
- Entalphy: "Entalphy",
1569
- shearStress: "Shear Stress, force parallel to surface",
1570
- volumeGradient: "Rate of Volume change per unit",
1571
- deg: "Degree, a unit of angular measurement",
1572
- dls: "Dogleg Severity, measure of wellbore curvature changes per unit length",
1573
- wgrad: "Weight Gradient, change in weight per unit length",
1574
- entalphy: "Entalphy, total heat content of a system",
1575
- pressurechange: "Change in pressure over time or between two points",
1576
- rpm: "Rotations per minute, a measure of the frequency of rotation, specifying the number of full rotations completed in one minute around a fixed axis",
1577
- sensorAccelerometer: "Strength of gravitational acceleration",
1578
- sensorMagnetometer: "Strength of magnetic forces at a position",
1579
- rotationalRate: "Rotational rate, the speed at which an object rotates around a fixed axis, typically measured in degrees per unit of time"
1580
- };
1581
- /**
1582
- * Description for the different units
1583
- * @readonly
1584
- */
1585
- const UNITS_DESCRIPTION = {
1586
- in: "Inches",
1587
- mm: "Milimeters",
1588
- cm: "Centimeters",
1589
- m: "Meters",
1590
- km: "Kilometers",
1591
- ft: "Feets",
1592
- usft: "US Feets",
1593
- in2: "Square inches",
1594
- cm2: "Square centimeters",
1595
- m2: "Square meters",
1596
- kg: "Kilograms",
1597
- tonnes: "Tonnes",
1598
- mt: "Metric tonnes",
1599
- kip: "Kip",
1600
- bbl: "Barrels",
1601
- Mm3: "Mega cubic meters",
1602
- MMSCF: "Million Standard Cubic Feet",
1603
- lbm: "Pound mass",
1604
- "kg/mol": "Kilograms per mole",
1605
- "lbf/mol": "Pounds per mole",
1606
- sg: "Specific gravity",
1607
- ppg: "Pounds per gallon",
1608
- "kg/m3": "Kilogram per cubic meters",
1609
- "lbm/ft3": "Pounds per cubic foot",
1610
- s: "Seconds",
1611
- min: "Minutes",
1612
- h: "Hours",
1613
- d: "Days",
1614
- month: "Months",
1615
- year: "Years",
1616
- "bbl/ft": "Barrels per foot",
1617
- lpm: "Litres per minute",
1618
- bpm: "Barrels per minute",
1619
- "m3/min": "Cubic meters per minute",
1620
- "m3/s": "Cubic meters per second",
1621
- MMSCFD: "Million Standard Cubic Feet per day",
1622
- "1/MMSCFD": "Inverse Million Standard Cubic Feet per day",
1623
- bar: "Bar",
1624
- Pa: "Pascals",
1625
- kPa: "Kilopascals",
1626
- MPa: "Megapascals",
1627
- kPsi: "Kilo pounds per square inch",
1628
- "kPa/m": "Kilopascals per meter",
1629
- "psi/ft": "Psi per foot",
1630
- "bar/100m": "Bars per 100m",
1631
- "psi/100ft": "Psi per 100ft",
1632
- "kPa/100m": "Kilopascals per 100m",
1633
- C: "Degrees Celsius",
1634
- F: "Degrees Fahrenheit",
1635
- K: "Kelvins",
1636
- "C/100m": "Degrees Celsius per 100m",
1637
- "F/100ft": "Degrees Fahrenheit per 100m",
1638
- "K/100m": "Kelvins per 100m",
1639
- "lbf/ft": "Pound force / foot",
1640
- "Pa/C": "Pascal per celsius",
1641
- "Bar/C": "Bar per celsius",
1642
- "psi/F": "Psi per fahrenheit",
1643
- "psi/C": "Psi per celsius",
1644
- N: "Newtons",
1645
- kN: "Kilo Newtons",
1646
- "N/m": "Newtons per meter",
1647
- "daN/m": "Decanewtons per meter",
1648
- lbf: "Pound force",
1649
- kgf: "Kilogram force",
1650
- rad: "Radians",
1651
- "BTU/lbm": "British Thermal Units per pound",
1652
- ppf: "Pound per foot",
1653
- "kg/m": "Kilograms per meter",
1654
- "E-06/degC": "Micro per degree Celsius",
1655
- "E-06/degF": "Micro per degree Fahrenheit",
1656
- km2: "Square kilometers",
1657
- ft2: "Square feet",
1658
- mm2: "Square millimeters",
1659
- mile2: "Square miles",
1660
- ft3: "Cubic feet",
1661
- "g/cm3": "Grams per cubic centimeter",
1662
- Sm3: "Standard cubic meter",
1663
- "ft3/s": "Cubic feet per second",
1664
- "ft3/d": "Cubic feet per day",
1665
- "m3/d": "Cubic meter per day",
1666
- "1/m3/d": "Inverse Cubic meter per day",
1667
- "s/m3": "Seconds per cubic meters",
1668
- "bbl/d": "Barrels per day",
1669
- tonneForce: "Tonne force",
1670
- USGal: "US gallon",
1671
- "g/mol": "Grams per mol",
1672
- Nm: "Newton meter",
1673
- kNm: "Kilo Newton meter",
1674
- ftlbf: "Foot pound",
1675
- "J/(kg*degC)": "Joules per kilogram degree Celsius",
1676
- "J/(kg*degK)": "Joules per kilogram degree Kelwin",
1677
- "BTU/(lbm*degF)": "British Thermal Unit per pound Fahrenheit",
1678
- "BTU/(h*ft*degF)": "British Thermal Units per hour feet degree Fahrenheit",
1679
- l: "Litres",
1680
- "l/m": "Litres per meter",
1681
- "kJ/kg": "Kilo joules per kilogram",
1682
- "J/kg": "Joules per kilogram",
1683
- deg: "Degrees",
1684
- "W/(mK)": "Watts per milli Kelvin",
1685
- psi: "Pounds per square inch",
1686
- "1/bar": "1/bar",
1687
- "1/psi": "1/psi",
1688
- "deg/100ft": "Degrees per 100ft",
1689
- "deg/10m": "Degrees per 10m",
1690
- "deg/30m": "Degrees per 30m",
1691
- "%": "Percent",
1692
- Hz: "Hertz",
1693
- "1/s": "Inverse second",
1694
- rpm: "Revolutions per minute",
1695
- "Pa/m": "Pascal per meter",
1696
- "bar/m": "Bar per meter",
1697
- gpm: "Gallons per minute",
1698
- "kg/s": "Kilograms per second",
1699
- "lbm/s": "Pound mass per second",
1700
- "tonnes/h": "Tonnes per hour",
1701
- "tons/h": "Tons per hour",
1702
- "deg/m": "Degrees per meter",
1703
- "deg/ft": "Degrees per foot",
1704
- "rad/m": "Radians per meter",
1705
- "rad/ft": "Radians per foot",
1706
- "dyn/cm": "Dyn per centimeter",
1707
- "mN/m": "Millinewtons per meter",
1708
- "1/kPa": "1/kPa",
1709
- m3: "Cubic meters",
1710
- "m/s": "Meters per second",
1711
- "ft/s": "Feet per second",
1712
- "m/min": "Meters per minute",
1713
- "ft/min": "Feet per min",
1714
- "m/h": "Meters per hour",
1715
- "ft/h": "Feet per hour",
1716
- mph: "Miles per hour",
1717
- "km/h": "Kilometers per hour",
1718
- "m/s2": "Meters per second squared",
1719
- "ft/s2": "Feet per second squared",
1720
- "Pa*s": "Pascal seconds",
1721
- P: "Poise (dyne second per square centimeter)",
1722
- "mPa*s": "Millipascal seconds",
1723
- cP: "Centi Poise",
1724
- W: "Watts",
1725
- hhp: "Hydraulic horsepower",
1726
- hp: "Horsepower",
1727
- kW: "Kilowatts",
1728
- MW: "Megawatts",
1729
- "BTU/h": "British Thermal Units per hour",
1730
- "hhp/in2": "Hydraulic horsepower per square inch",
1731
- "hhp/ft2": "Hydraulic horsepower per square feet",
1732
- "Mm3/d": "Mega cubic meters per day",
1733
- "STB/d": "Stock Tank Barrel per day",
1734
- "Sm3/d": "Standard cubic meters per day",
1735
- "Sm3/min": "Standard cubic meters per minute",
1736
- "MSm3/d": "Mega standard cubic meters per day",
1737
- "SCF/STB": "Standard Cubic Feet per Stock Tank Barrel",
1738
- "Sm3/Sm3": "Standard cubic meters per Standard cubic meter",
1739
- "SCF/d": "Standard cubic feet per day",
1740
- STB: "Stock Tank Barrel",
1741
- SCF: "Standard Cubic Feet",
1742
- Gsg: "Gas - specific gravity",
1743
- Gppg: "Gas - pounds per gallon",
1744
- "Gkg/m3": "Gas - kilogram per cubic meters",
1745
- "Glbm/ft3": "Gas - pounds per cubic foot",
1746
- MSm3: "Mega standard cubic meters",
1747
- "m3/s/bar": "Cubic per second per bar",
1748
- "Sm3/d/bar": "Standard cubic per day per bar",
1749
- "STB/d/psi": "Standard barrels per day per psi",
1750
- klbf: "kilopound force",
1751
- "1/Pa": "1/Pascal",
1752
- "1/MPa": "1/MPa",
1753
- ksi: "Kilopound per square inch",
1754
- "lbf/100ft2": "Pounds per 100 square foot",
1755
- "lb/ft3": "lb/ft3",
1756
- "°N": "°N (latitude)",
1757
- "°S": "°S (latitude)",
1758
- "°W": "°W (longitude)",
1759
- "°E": "°E (longitude)",
1760
- fr: "Fraction",
1761
- mD: "Millidarcy",
1762
- Sigma: "Sigma",
1763
- CI: "Confidence Interval",
1764
- "J/(s*m*degK)": "Joules per second meter Kelvin",
1765
- "C/m": "Degrees Celsius per meter",
1766
- "F/ft": "Degrees Fahrenheit per meter",
1767
- "K/m": "Kelvin per meter",
1768
- microM: "Micro meter",
1769
- "W/m2": "Watt per square meter",
1770
- "1/K": "Inverse Kelvin",
1771
- "lb/ft": "Pound Per Feet",
1772
- "E-09/bar": "Nano per bar",
1773
- "E-10/psi": "10⁻¹⁰ per psi",
1774
- "E-14/pa": "10⁻¹⁴ per pascal",
1775
- lk: "Link",
1776
- ftCla: "Clark`s foot",
1777
- lkCla: "Clark`s link",
1778
- ftSe: "British foot (Sears 1922)",
1779
- ydSe: "British yard (Sears 1922)",
1780
- chSe: "British chain (Sears 1922)",
1781
- "chSe(T)": "British chain (Sears 1922 Truncated)",
1782
- ftGC: "Gold Coast foot",
1783
- ydInd: "Indian yard",
1784
- "d/stand": "Day per stand",
1785
- "h/stand": "Hour per stand",
1786
- "min/stand": "Minute per stand",
1787
- "s/stand": "Second per stand",
1788
- "m3/t": "Cubic meter per ton",
1789
- "L/100kg": "Liter per 100kg",
1790
- GPa: "Gigapascals, unit of pressure",
1791
- "cm3/m": "Cubic cm per meter",
1792
- "in3/ft": "Cubic inches per foot",
1793
- "ft3/ft": "Cubic feet per foot",
1794
- "m3/m": "Cubic meters per meter",
1795
- "mm3/m": "Cubic millimeters per meter",
1796
- "1/GPa": "Inverse gigapascal",
1797
- lps: "Liters per second",
1798
- nT: "nanoTesla",
1799
- Gs: "Gauss",
1800
- g: "g force",
1801
- "deg/h": "Degrees per hour"
1802
- };
1803
- //#endregion
1804
- //#region src/units/unit-catalog.ts
1805
- /** Returns the units configured for a quantity key. */
1806
- function showAltUnitsList(quantityKey) {
1807
- return ALT_UNITS[quantityKey];
1808
- }
1809
- /** Returns the units configured for a quantity. */
1810
- function getUnitsForQuantity(quantity) {
1811
- return showAltUnitsList(quantity);
1812
- }
1813
- /** Returns all configured quantity keys. */
1814
- function getQuantities() {
1815
- return Object.keys(ALT_UNITS);
1816
- }
1817
- /** Returns the display label for a unit key. */
1818
- function label(unitKey) {
1819
- return LABELS[unitKey];
1820
- }
1821
- /** Returns the base unit configured for a quantity. */
1822
- function unitFromKey(quantity) {
1823
- return UNIT_FROM_KEY[quantity];
1824
- }
1825
- /** Alias for `unitFromKey`. */
1826
- function unitFromQuantity(quantity) {
1827
- return unitFromKey(quantity);
1828
- }
1829
- /** Returns the alternative units and their display labels for a quantity. */
1830
- function getAltUnitsListByQuantity(quantity) {
1831
- const quantityUnitList = showAltUnitsList(quantity);
1832
- return quantityUnitList ? quantityUnitList.map((unit) => ({
1833
- unit,
1834
- label: label(unit)
1835
- })) : void 0;
1836
- }
1837
- //#endregion
1838
- //#region src/numbers/parsing/number-input.ts
1839
- /** Basic trimming of numeric input strings. */
1840
- const trim = (value) => {
1841
- return value.trim().replace(/[\t\r\n]/g, "");
1842
- };
1843
- /** Counts occurrences of a character in a string. */
1844
- function charCount(character, value) {
1845
- const singleCharacter = String(character)[0];
1846
- let total = 0;
1847
- let lastLocation = value.indexOf(singleCharacter, 0) + 1;
1848
- while (lastLocation > 0) {
1849
- lastLocation = value.indexOf(singleCharacter, lastLocation) + 1;
1850
- total += 1;
1851
- }
1852
- return total;
1853
- }
1854
- /** Normalizes supported decimal and thousands separators in a numeric input string. */
1855
- function cleanNumStr(value) {
1856
- let cleanString = trim(String(value));
1857
- const slashCount = charCount("/", cleanString);
1858
- const spaceCount = charCount(" ", cleanString) + charCount("\xA0", cleanString);
1859
- let dotCount = charCount(".", cleanString);
1860
- let commaCount = charCount(",", cleanString);
1861
- if (slashCount === 0 && spaceCount > 0) cleanString = cleanString.replace(/\s/g, "");
1862
- if (commaCount > 1) cleanString = cleanString.replace(/,/g, "");
1863
- if (dotCount > 1) cleanString = cleanString.replace(/\./g, "");
1864
- commaCount = charCount(",", cleanString);
1865
- dotCount = charCount(".", cleanString);
1866
- if (dotCount === 1 && commaCount === 1) {
1867
- if (cleanString.indexOf(",") > cleanString.indexOf(".")) {
1868
- cleanString = cleanString.replace(".", "");
1869
- cleanString = cleanString.replace(",", ".");
1870
- } else cleanString = cleanString.replace(",", "");
1871
- if (cleanString.indexOf(".") === 0) cleanString = `0${cleanString}`;
1872
- return cleanString;
1873
- }
1874
- if (!dotCount && commaCount) cleanString = cleanString.replace(",", ".");
1875
- if (cleanString.indexOf(".") === 0) cleanString = `0${cleanString}`;
1876
- return cleanString;
1877
- }
1878
- /** Removes redundant leading zeros while preserving the sign and fractional part. */
1879
- const stripLeadingZeros = (value) => {
1880
- const isMinus = value?.[0] === "-";
1881
- const cleanedValue = value.replace(/^-/gm, "").replace(/^(?:0+(?=[1-9])|0+(?=0))/gm, "");
1882
- return isMinus ? `-${cleanedValue}` : cleanedValue;
1883
- };
1884
- /** Normalizes a numeric input string and parses it as a number. */
1885
- function cleanNum(value) {
1886
- if (typeof value === "number") return value;
1887
- return parseFloat(cleanNumStr(value));
1888
- }
1889
- const isNull = (value) => {
1890
- return value === null;
1891
- };
1892
- const isUndefined = (value) => {
1893
- return value === void 0;
1894
- };
1895
- const isArray = (value) => {
1896
- return Boolean(value) && value.constructor === Array;
1897
- };
1898
- const isObject = (value) => {
1899
- return Boolean(value) && value.constructor === Object;
1900
- };
1901
- const isEmptyString = (value) => {
1902
- return value === "";
1903
- };
1904
- const isTrailingPeriodSeparator = (value) => {
1905
- return Boolean(value) && String(value)[String(value).length - 1] === ".";
1906
- };
1907
- const isTrailingCommaSeparator = (value) => {
1908
- return Boolean(value) && String(value)[String(value).length - 1] === ",";
1909
- };
1910
- //#endregion
1911
- //#region src/units/unit-string.ts
1912
- const SEPARATOR = "|";
1913
- const UNIT_RE = /^(-?[0-9., /]*?(?:e[-+]?[0-9]+)?)([^0-9-., /].*)?$/;
1914
- /** Checks whether a unit string has an empty numeric part, for example `|m`. */
1915
- function isEmptyValueWithUnit(value) {
1916
- return typeof value === "string" && value.length > 0 && value.startsWith("|");
1917
- }
1918
- /** Splits a supported unit string into its numeric and unit parts. */
1919
- function split(valueWithUnit) {
1920
- let match;
1921
- let normalizedValue = valueWithUnit !== void 0 && valueWithUnit !== null ? String(valueWithUnit) : "";
1922
- if (charCount("|", normalizedValue) > 1) {
1923
- match = normalizedValue.split("|");
1924
- normalizedValue = match.slice(0, -1).join("") + "|" + match.slice(-1);
1925
- }
1926
- if (normalizedValue.indexOf("|") >= 0) match = normalizedValue.split("|");
1927
- else if (SPECIAL_NUMBERS_STRING.includes(normalizedValue)) match = [normalizedValue, ""];
1928
- else {
1929
- match = cleanNumStr(normalizedValue).match(UNIT_RE);
1930
- if (match) match = match.slice(1);
1931
- }
1932
- if (!match) match = ["0", ""];
1933
- if (match[1] == null) match[1] = "";
1934
- return [match[0], match[1]];
1935
- }
1936
- /** Returns the numeric part of a unit string. */
1937
- function getValue(valueWithUnit) {
1938
- return split(valueWithUnit)[0];
1939
- }
1940
- /** Returns the unit part of a unit string. */
1941
- function getUnit(valueWithUnit) {
1942
- return split(valueWithUnit)[1];
1943
- }
1944
- /** Checks whether a value contains exactly one known unit suffix. */
1945
- function isValueWithUnit(value) {
1946
- if (!value) return false;
1947
- const parts = String(value).split("|");
1948
- return parts.length === 2 && KNOWN_UNITS.includes(parts[1]);
1949
- }
1950
- /** Joins a value and unit using the package unit separator. */
1951
- function withUnit(value, unit, defaultValue = "") {
1952
- if (value === null || value === "" || value === void 0) value = defaultValue;
1953
- if (unit === null) return String(value);
1954
- let [normalizedValue, normalizedUnit] = String(value).includes("|") ? split(String(value)) : [value, unit];
1955
- if (!normalizedUnit) normalizedUnit = unit;
1956
- return [normalizedValue, normalizedUnit].join("|");
1957
- }
1958
- /** Replaces a unit key in a unit string with its display label. */
1959
- function withPrettyUnitLabel(valueWithUnits) {
1960
- const [value, unit] = split(valueWithUnits);
1961
- return `${value} ${LABELS[unit] ?? ""}`;
1962
- }
1963
- //#endregion
1964
- //#region src/numbers/fractions/fractions.ts
1965
- const normalizeFractionWhitespace = (value) => {
1966
- return value.trim().replace(/\s+/g, " ");
1967
- };
1968
- /** Checks whether a string can be parsed as a fraction by fraction.js. */
1969
- const isFraction = (value) => {
1970
- if (typeof value !== "string" || !value.includes("/")) return false;
1971
- try {
1972
- new fraction_js.default(normalizeFractionWhitespace(value));
1973
- return true;
1974
- } catch (error) {
1975
- return error.message === "Division by Zero";
1976
- }
1977
- };
1978
- /** Converts a fraction to its decimal value, or returns `NaN` when it cannot be parsed. */
1979
- function fraction(value) {
1980
- if (value instanceof Array || value === null || value === void 0) return NaN;
1981
- if (typeof value === "string") value = normalizeFractionWhitespace(value);
1982
- if (value === "") return NaN;
1983
- let result = NaN;
1984
- let infinite = false;
1985
- try {
1986
- const fractionObject = new fraction_js.default(value);
1987
- if (fractionObject !== void 0) result = fractionObject.valueOf();
1988
- } catch (error) {
1989
- if (error instanceof Error && error.message === "Division by Zero") infinite = true;
1990
- }
1991
- return infinite ? Infinity : result;
1992
- }
1993
- /** Converts a decimal value to a fractional string. */
1994
- function asFraction(value) {
1995
- if (typeof value === "string") value = normalizeFractionWhitespace(value);
1996
- if (value === "") value = "0";
1997
- return new fraction_js.default(value).toFraction(true);
1998
- }
1999
- /**
2000
- * Converts a fraction string to a number.
2001
- *
2002
- * For compatibility, invalid inputs are returned unchanged and division by zero returns signed infinity.
2003
- */
2004
- function numFraction(value) {
2005
- if (value instanceof Array || value === null || value === void 0 || value === "" || value === Infinity || value === -Infinity || value === "Infinity" || value === "-Infinity" || Number.isNaN(value) || value === "NaN") return value;
2006
- if (typeof value === "string") value = normalizeFractionWhitespace(value);
2007
- let result = value;
2008
- try {
2009
- const fractionObject = new fraction_js.default(value);
2010
- if (fractionObject !== void 0) result = fractionObject.valueOf();
2011
- } catch (error) {
2012
- if (error.message === "Division by Zero") return value.charAt(0) === "-" ? -Infinity : Infinity;
2013
- console.warn("Error in numFraction() method: ", value);
2014
- }
2015
- return result.valueOf();
2016
- }
2017
- //#endregion
2018
- //#region src/numbers/scientific-notation/scientific-notation.ts
2019
- const EXP_NOTATION_RE = /^[-+]?[0-9]*\.?[0-9]+(?:\/[0-9]*\.?[0-9]+)?(?:[eE][-+]?[0-9]+)?$/;
2020
- /** Normalizes whitespace and mantissa syntax in a scientific-notation string. */
2021
- const normalizeExponent = (input) => {
2022
- return input.replace(/^([+-]?(?:\d+\.?\d*|\.\d+))[ ]*[eE][ ]*([+-]?[ ]*\d+)/, (_match, mantissa, exponent) => {
2023
- let normalizedMantissa = mantissa.endsWith(".") ? mantissa.slice(0, -1) : mantissa;
2024
- if (normalizedMantissa.startsWith(".")) normalizedMantissa = `0${normalizedMantissa}`;
2025
- const normalizedExponent = exponent.replace(/[ ]+/g, "");
2026
- return `${normalizedMantissa}e${normalizedExponent}`;
2027
- });
2028
- };
2029
- /** Normalizes scientific notation while preserving an optional unit suffix. */
2030
- function normalizeScientific(value) {
2031
- if (typeof value !== "string") return value;
2032
- const normalizedSpaces = value.replace(/\u00A0|\u2007|\u202F/g, " ").trim();
2033
- if (isValueWithUnit(normalizedSpaces)) {
2034
- const [number, unit] = split(normalizedSpaces);
2035
- return `${normalizeExponent(number.trim())}|${unit.trim()}`;
2036
- }
2037
- const match = normalizedSpaces.match(/^([+-]?(?:\d+(?:\.\d*)?|\.\d+)\s*[eE]\s*[+-]?\s*\d+)\s+(.+)$/);
2038
- if (match) return `${normalizeExponent(match[1])}|${match[2].trim()}`;
2039
- return normalizeExponent(normalizedSpaces);
2040
- }
2041
- //#endregion
2042
- //#region src/numbers/predicates.ts
2043
- /** Checks whether a value is supported as a finite numeric or fraction input. */
2044
- function isNumeric(value) {
2045
- if (value === void 0 || value === null || Array.isArray(value) || typeof value === "object" || Number.isNaN(value) || value === "NaN" || value === Infinity || value === -Infinity || value === "Infinity" || value === "-Infinity") return false;
2046
- if (isFraction(value)) return true;
2047
- return typeof value === "string" ? !isNaN(parseFloat(value)) && (EXP_NOTATION_RE.test(value) || isFinite(value)) : isFinite(value);
2048
- }
2049
- const isNonNumerical = (value) => {
2050
- return !isNumeric(value);
2051
- };
2052
- const isPercentage = (value) => {
2053
- return typeof value === "string" && /^\d+(\.\d+)?%$/.test(value);
2054
- };
2055
- function allNumbers(values) {
2056
- return !values.some((value) => typeof value !== "number");
2057
- }
2058
- //#endregion
2059
- //#region src/numbers/parsing/parse-number.ts
2060
- const countTrailingZeros = (value, decimalPartOnly = false) => {
2061
- const condition = decimalPartOnly ? /0+((?=[|eE])|$)/ : /(0+|0+\.0+)((?=[|eE])|$)/;
2062
- if (typeof value === "string" && (decimalPartOnly ? value.includes(".") || value.includes(",") : true)) return value?.match(condition)?.[0]?.replaceAll(/[.,]/g, "")?.length ?? 0;
2063
- return 0;
2064
- };
2065
- const hasTrailingZeros = (value) => {
2066
- return countTrailingZeros(value) > 0;
2067
- };
2068
- /**
2069
- * Internal function to parse the value, unit, and type from a generic numeric input
2070
- *
2071
- * Accepts number types (1.234), stringified numbers ('1.234'), and unit numbers ('1.234|m')
2072
- *
2073
- * @param value
2074
- * @returns object with number, unit, and type
2075
- */
2076
- const parseNumber = (value, preserveTrailingZeros = false) => {
2077
- const isString = typeof value === "string";
2078
- const hasUnit = isString && isValueWithUnit(value);
2079
- const unit = hasUnit ? getUnit(value) : null;
2080
- const cleaned = cleanNumStr(hasUnit ? getValue(value) : value);
2081
- return {
2082
- number: preserveTrailingZeros && hasTrailingZeros(value) ? cleaned : toNum(cleaned),
2083
- unit,
2084
- isString
2085
- };
2086
- };
2087
- /**
2088
- * Convert a number to a string safely, better than String(value)
2089
- * String(0.0000002) returns '2e-7' which is unwanted if we need to preserve formatting
2090
- *
2091
- * @param value
2092
- * @param [isScientific] whether to preserve scientific notation
2093
- * @returns number or string output value
2094
- */
2095
- const safeStringifyNumber = (value, isScientific) => {
2096
- return isScientific ? String(value) : toString(value);
2097
- };
2098
- /**
2099
- * Internal function to unParse a value, unit, and type back to an output value
2100
- *
2101
- * Accepts number types (1.234), stringified numbers ('1.234'), and unit numbers ('1.234|m')
2102
- *
2103
- * @param args
2104
- * @param args.value
2105
- * @param args.unit
2106
- * @param args.isString
2107
- * @param args.isScientific
2108
- * @returns number or string output value
2109
- */
2110
- const unParseNumber = ({ value, unit, isString, isScientific }) => {
2111
- const convertedValue = typeof value === "number" && isString ? safeStringifyNumber(value, isScientific) : value;
2112
- if (unit) return withUnit(convertedValue, unit);
2113
- return convertedValue;
2114
- };
2115
- //#endregion
2116
- //#region src/numbers/comparison/comparison.ts
2117
- const DEFAULT_MAX_RELATIVE_DIFF = Number.EPSILON;
2118
- const convertNumbers = (firstValue, secondValue) => {
2119
- const { number: firstNumber, unit: firstUnit } = parseNumber(firstValue);
2120
- const { number: secondNumber, unit: secondUnit } = parseNumber(secondValue);
2121
- return {
2122
- firstNumber,
2123
- secondNumber: firstUnit && secondUnit && firstUnit !== secondUnit ? convertAndGetValue(secondNumber, firstUnit, secondUnit) : secondNumber
2124
- };
2125
- };
2126
- const getToleranceNumber = (relativeDiff) => {
2127
- if (relativeDiff !== null && relativeDiff !== void 0) {
2128
- if (isNumeric(relativeDiff) && typeof relativeDiff === "number") return relativeDiff;
2129
- if (isPercentage(relativeDiff)) {
2130
- const percentageValue = toNum(relativeDiff?.toString().replace("%", ""));
2131
- if (isNumeric(percentageValue)) return percentageValue / 100;
2132
- }
2133
- }
2134
- return null;
2135
- };
2136
- /**
2137
- * Determines whether two numbers are close in value with a tolerance
2138
- * (mitigates excess JavaScript floating point precision quirks)
2139
- */
2140
- const isCloseTo = (firstValue, secondValue, options = { relativeDiff: DEFAULT_MAX_RELATIVE_DIFF }) => {
2141
- const { relativeDiff, absoluteDiff } = options;
2142
- const toleranceNumber = getToleranceNumber(relativeDiff ?? absoluteDiff);
2143
- if (firstValue === null || secondValue === null) return false;
2144
- const hasUnitFirstValue = isValueWithUnit(firstValue);
2145
- const hasUnitSecondValue = isValueWithUnit(secondValue);
2146
- if (hasUnitFirstValue && !hasUnitSecondValue || !hasUnitFirstValue && hasUnitSecondValue) throw new Error(`Parameters must either both have units or both not have units. Received "${firstValue}" and "${secondValue}"`);
2147
- if (toleranceNumber === null) {
2148
- console.warn("Tolerance number is not defined!");
2149
- return firstValue === secondValue;
2150
- }
2151
- if (toleranceNumber <= 0 || toleranceNumber < Number.EPSILON) throw Error("Unpredictable results - toleranceNumber should be bigger than zero or less then EPSILON");
2152
- const { firstNumber, secondNumber } = convertNumbers(firstValue, secondValue);
2153
- if ((firstNumber === Infinity || firstNumber === "Infinity") && (secondNumber === Infinity || secondNumber === "Infinity") || (firstNumber === -Infinity || firstNumber === "-Infinity") && (secondNumber === -Infinity || secondNumber === "-Infinity")) return true;
2154
- if (typeof firstNumber === "number" && typeof secondNumber === "number") {
2155
- if (firstNumber === secondNumber) return true;
2156
- if (absoluteDiff || firstNumber === 0 || secondNumber === 0) {
2157
- const diff = Math.abs(firstNumber - secondNumber);
2158
- return isCloseTo(diff, toleranceNumber, { relativeDiff: "1%" }) || diff < toleranceNumber;
2159
- } else return 2 * Math.abs((firstNumber - secondNumber) / (firstNumber + secondNumber)) < toleranceNumber;
2160
- }
2161
- return false;
2162
- };
2163
- /**
2164
- * Determines whether two numbers are close enough to be equal
2165
- * or checks the firstValue is greater than the secondValue
2166
- */
2167
- const isCloseToOrGreaterThan = (firstValue, secondValue, options = { relativeDiff: DEFAULT_MAX_RELATIVE_DIFF }) => {
2168
- if (firstValue === null || secondValue === null) return false;
2169
- const { firstNumber, secondNumber } = convertNumbers(firstValue, secondValue);
2170
- if (typeof firstNumber === "number" && typeof secondNumber === "number") return isCloseTo(firstNumber, secondNumber, options) || firstNumber > secondNumber;
2171
- return false;
2172
- };
2173
- /**
2174
- * Determines whether two numbers are close enough to be equal
2175
- * or checks the firstValue is less than the secondValue
2176
- */
2177
- const isCloseToOrLessThan = (firstValue, secondValue, options = { relativeDiff: DEFAULT_MAX_RELATIVE_DIFF }) => {
2178
- if (firstValue === null || secondValue === null) return false;
2179
- const { firstNumber, secondNumber } = convertNumbers(firstValue, secondValue);
2180
- if (typeof firstNumber === "number" && typeof secondNumber === "number") return isCloseTo(firstNumber, secondNumber, options) || firstNumber < secondNumber;
2181
- return false;
2182
- };
2183
- /**
2184
- * Determines whether two objects or arrays are deeply close equal (all nested child numbers)
2185
- */
2186
- const isDeepCloseTo = (a, b, options = { relativeDiff: DEFAULT_MAX_RELATIVE_DIFF }) => {
2187
- if (Array.isArray(a) && Array.isArray(b)) {
2188
- if (a.length !== b.length) return false;
2189
- return a.every((a, i) => isDeepCloseTo(a, b[i], options));
2190
- }
2191
- if (typeof a === "object" && a !== null && typeof b === "object" && b !== null) {
2192
- const aKeys = Object.keys(a);
2193
- const bKeys = Object.keys(b);
2194
- if (aKeys.length !== bKeys.length) return false;
2195
- return aKeys.every((key) => isDeepCloseTo(a[key], b[key], options));
2196
- }
2197
- if (Number.isNaN(a) && Number.isNaN(b) || a === "" && b === "") return true;
2198
- if (typeof a === "number" && typeof b === "number" || isValueWithUnit(a) && isValueWithUnit(b) || isValidNum(a) && isValidNum(b)) return isCloseTo(a, b, options);
2199
- return true;
2200
- };
2201
- //#endregion
2202
- //#region src/numbers/rounding/rounding.ts
2203
- const DEFAULT_SIGNIFICANT_DIGITS = 4;
2204
- /**
2205
- * Rounds a number to N decimal places.
2206
- *
2207
- * @private (see round() for the public interface)
2208
- * @param value
2209
- * @param [n]
2210
- * @returns rounded number
2211
- */
2212
- const roundNumber = (value, n = DEFAULT_SIGNIFICANT_DIGITS) => {
2213
- const factor = 10 ** n;
2214
- return Math.round(value * factor) / factor;
2215
- };
2216
- /**
2217
- * Rounds a numeric value to N decimal places.
2218
- *
2219
- * - accepts number types (1.234), stringified numbers ('1.234'), and unit numbers ('1.234|m')
2220
- * - returns same type as input
2221
- *
2222
- * @param value - the value to round
2223
- * @param [n] - the number of decimal places to round to
2224
- * @returns rounded value, or input value when unable to round
2225
- *
2226
- * @example
2227
- * round(3.14159265) -> 3.1416
2228
- */
2229
- const round = (value, n = DEFAULT_SIGNIFICANT_DIGITS) => {
2230
- if (typeof value === "number") return roundNumber(value, n);
2231
- if (value === null || Number.isNaN(value) || value === Infinity || value === -Infinity || value === void 0) return value;
2232
- const { number, unit, isString } = parseNumber(value);
2233
- return unParseNumber({
2234
- value: !isNumeric(number) || typeof number === "string" && number.endsWith(".") ? value : roundNumber(number, n),
2235
- unit,
2236
- isString,
2237
- isScientific: isScientificStringNum(value)
2238
- });
2239
- };
2240
- /**
2241
- * Rounds a number to N significant digits.
2242
- *
2243
- * @private (see roundToPrecision() for the public interface)
2244
- * @param value
2245
- * @param [n] number of significant digits
2246
- * @returns rounded number
2247
- */
2248
- const roundNumberToPrecision = (value, n = DEFAULT_SIGNIFICANT_DIGITS) => {
2249
- return Number(value.toPrecision(n));
2250
- };
2251
- /**
2252
- * Rounds a number to N significant digits, preserving trailing decimal zeros
2253
- *
2254
- * @private (see roundByMagnitudeToFixed() for the public interface)
2255
- * @param value
2256
- * @param [n] number of significant digits
2257
- * @returns rounded number as string
2258
- */
2259
- const roundNumberToFixedPrecision = (value, n = DEFAULT_SIGNIFICANT_DIGITS) => {
2260
- const [integerPart, decimalPart] = toNum(value).toPrecision(n).split(".");
2261
- if (decimalPart) {
2262
- const decimalDigits = n - integerPart.length;
2263
- return `${integerPart}.${decimalPart.padEnd(decimalDigits, "0")}`;
2264
- } else return integerPart;
2265
- };
2266
- /**
2267
- * Rounds a number to N significant digits, excluding the integer part (only rounds decimal part)
2268
- *
2269
- * @private (see roundToPrecision() for the public interface)
2270
- * @param value
2271
- * @param [n] number of significant digits
2272
- * @returns rounded number
2273
- */
2274
- const roundNumberToDecimalPrecision = (value, n = DEFAULT_SIGNIFICANT_DIGITS) => {
2275
- if (Math.abs(value) > 1) {
2276
- const [integerPart, decimalPart] = formatDecimal(value, "").split(".");
2277
- if (!decimalPart) return value;
2278
- else {
2279
- const roundedDecimalPart = Number(`0.${decimalPart}`).toPrecision(n).slice(1);
2280
- return Number(integerPart + roundedDecimalPart);
2281
- }
2282
- }
2283
- return roundNumberToPrecision(value, n);
2284
- };
2285
- /**
2286
- * Rounds a numeric value to N significant digits.
2287
- *
2288
- * - accepts number types (1.234), stringified numbers ('1.234'), and unit numbers ('1.234|m')
2289
- * - returns same type as input
2290
- * - similar to Number.toPrecision() but safer
2291
- * - does *not* append trailing zeros (unlike `Number(4).toPrecision(4)` -> '4.000')
2292
- *
2293
- * @param value - the value to round
2294
- * @param [n] - the number of significant digits
2295
- * @returns rounded value, or input value when unable to round
2296
- *
2297
- * @example
2298
- * roundToPrecision(0.0000456789) -> 0.00004568
2299
- */
2300
- const roundToPrecision = (value, n = DEFAULT_SIGNIFICANT_DIGITS) => {
2301
- if (typeof value === "number") return roundNumberToPrecision(value, n);
2302
- if (value === null || Number.isNaN(value) || value === Infinity || value === -Infinity || value === void 0) return value;
2303
- const { number, unit, isString } = parseNumber(value);
2304
- return unParseNumber({
2305
- value: !isNumeric(number) || typeof number === "string" && number.endsWith(".") ? value : roundNumberToPrecision(number, n),
2306
- unit,
2307
- isString,
2308
- isScientific: isScientificStringNum(value)
2309
- });
2310
- };
2311
- /**
2312
- * Rounds a numeric value to N significant digits (only the decimal part)
2313
- *
2314
- * - accepts number types (1.234), stringified numbers ('1.234'), and unit numbers ('1.234|m')
2315
- * - returns same type as input
2316
- * - unlike roundToPrecision(), acts only on the decimal part, not the integer part too
2317
- *
2318
- * @param value - the value to round
2319
- * @param [n]- the number of significant digits
2320
- * @returns rounded value, or input value when unable to round
2321
- *
2322
- * @example
2323
- * roundToPrecision(1234.0000456789) -> 1234.00004568
2324
- */
2325
- const roundToDecimalPrecision = (value, n = DEFAULT_SIGNIFICANT_DIGITS) => {
2326
- if (typeof value === "number") return roundNumberToDecimalPrecision(value, n);
2327
- if (value === null || Number.isNaN(value) || value === Infinity || value === -Infinity || value === void 0) return value;
2328
- const { number, unit, isString } = parseNumber(value);
2329
- return unParseNumber({
2330
- value: !isNumeric(number) || typeof number === "string" && number.endsWith(".") ? value : roundNumberToDecimalPrecision(number, n),
2331
- unit,
2332
- isString,
2333
- isScientific: isScientificStringNum(value)
2334
- });
2335
- };
2336
- /**
2337
- * Rounds a number to an appropriate number of digits, based on its size.
2338
- *
2339
- * @private (see roundByMagnitude() for the public interface)
2340
- * @param value
2341
- * @param [n] the number of significant digits
2342
- * @param [toFixed] to fixed digits (i.e. with trailing zeros)
2343
- * @returns rounded number
2344
- */
2345
- const roundNumberByMagnitude = (value, n = DEFAULT_SIGNIFICANT_DIGITS, toFixed = false) => {
2346
- const noDecimalsAbove = 10 ** n;
2347
- const result = noDecimalsAbove && value > noDecimalsAbove ? roundNumber(value, 0) : toFixed ? roundNumberToFixedPrecision(value, n) : roundNumberToPrecision(value, n);
2348
- return toFixed ? String(result) : result;
2349
- };
2350
- /**
2351
- * Rounds a numeric value to an appropriate number of digits, based on its size. It rounds to N significant digits,
2352
- * but never rounds the integer part.
2353
- *
2354
- * - accepts number types (1.234), stringified numbers ('1.234'), and unit numbers ('1.234|m')
2355
- * - returns same type as input
2356
- *
2357
- * @param value - the value to round
2358
- * @param [n] - the number of significant digits
2359
- * @returns rounded value, or input value when unable to round
2360
- *
2361
- * @example
2362
- * roundByMagnitude(0.000123456789) -> 0.0001235
2363
- * roundByMagnitude(1.123456789) -> 1.123
2364
- * roundByMagnitude(19999.123456789) -> 19999
2365
- */
2366
- const roundByMagnitude = (value, n = DEFAULT_SIGNIFICANT_DIGITS) => {
2367
- if (typeof value === "number") return roundNumberByMagnitude(value, n);
2368
- if (value === null || Number.isNaN(value) || value === Infinity || value === -Infinity || value === void 0) return value;
2369
- const { number, unit, isString } = parseNumber(value);
2370
- return unParseNumber({
2371
- value: !isNumeric(number) || typeof number === "string" && number.endsWith(".") ? value : roundNumberByMagnitude(number, n),
2372
- unit,
2373
- isString,
2374
- isScientific: isScientificStringNum(value)
2375
- });
2376
- };
2377
- /**
2378
- * Rounds a numeric value to an appropriate number of digits, based on its size. It rounds to N significant digits,
2379
- * but never rounds the integer part. Similar to roundByMagnitude, but adds trailing zeros.
2380
- *
2381
- * - accepts number types (1.234), stringified numbers ('1.234'), and unit numbers ('1.234|m')
2382
- * - returns string type (or original value and type when not possible to convert)
2383
- *
2384
- * @param value - the value to round
2385
- * @param [n] - the number of significant digits
2386
- * @returns rounded value as a string, or input value when unable to round
2387
- *
2388
- * @example
2389
- * roundByMagnitudeToFixed(0.000120016789) -> 0.0001200
2390
- */
2391
- const roundByMagnitudeToFixed = (value, n = DEFAULT_SIGNIFICANT_DIGITS) => {
2392
- const toFixed = true;
2393
- if (value === null || Number.isNaN(value) || value === Infinity || value === -Infinity || value === void 0) return value;
2394
- if (typeof value === "number") return roundNumberByMagnitude(value, n, toFixed);
2395
- const { number, unit } = parseNumber(value, true);
2396
- return unParseNumber({
2397
- value: !isNumeric(number) || typeof number === "string" && number.endsWith(".") ? value : roundNumberByMagnitude(number, n, toFixed),
2398
- unit,
2399
- isString: true,
2400
- isScientific: isScientificStringNum(value)
2401
- });
2402
- };
2403
- /**
2404
- * Rounds a number to an appropriate number of digits, based on its size in relation to a range.
2405
- *
2406
- * @private (see roundByMagnitude() for the public interface)
2407
- * @param value
2408
- * @param min
2409
- * @param max
2410
- * @param [n] the minimum number of significant digits
2411
- * @returns rounded number
2412
- */
2413
- const roundNumberByRange = (value, min, max, n = DEFAULT_SIGNIFICANT_DIGITS) => {
2414
- if (isCloseToOrLessThan(max, min)) return value;
2415
- const range = max - min;
2416
- return roundNumber(value, Math.max(n, 0 - Math.floor(Math.log10(range))));
2417
- };
2418
- /**
2419
- * Rounds a numeric value to an appropriate number of digits, based on its size within a range of values.
2420
- *
2421
- * - accepts number types (1.234), stringified numbers ('1.234'), and unit numbers ('1.234|m')
2422
- * - returns same type as input
2423
- *
2424
- * @param value - the value to round
2425
- * @param min - the min value in the range
2426
- * @param max - the max value in the range
2427
- * @param [n] - the minimum number of significant digits
2428
- * @returns rounded value, or input value when unable to round
2429
- *
2430
- */
2431
- const roundByRange = (value, min, max, n = DEFAULT_SIGNIFICANT_DIGITS) => {
2432
- if (typeof value === "number") return roundNumberByRange(value, min, max, n);
2433
- if (value === null || Number.isNaN(value) || value === Infinity || value === -Infinity || value === void 0) return value;
2434
- const { number, unit, isString } = parseNumber(value);
2435
- return unParseNumber({
2436
- value: !isNumeric(number) || typeof number === "string" && number.endsWith(".") ? value : roundNumberByRange(number, min, max, n),
2437
- unit,
2438
- isString,
2439
- isScientific: isScientificStringNum(value)
2440
- });
2441
- };
2442
- /**
2443
- * Rounds a numeric value to N fixed decimal digits.
2444
- *
2445
- * - accepts number types (1.234), stringified numbers ('1.234'), and unit numbers ('1.234|m')
2446
- * - returns same type as input
2447
- *
2448
- * @param value - the value to round
2449
- * @param [n] - the number of fixed decimal digits
2450
- * @returns rounded value, or input value when unable to round
2451
- *
2452
- */
2453
- const roundToFixed = (value, n = DEFAULT_SIGNIFICANT_DIGITS) => {
2454
- if (value === null || Number.isNaN(value) || value === Infinity || value === -Infinity || value === void 0) return value;
2455
- if (typeof value === "number") return value.toFixed(n);
2456
- const { number, unit, isString } = parseNumber(value);
2457
- return unParseNumber({
2458
- value: !isNumeric(number) || typeof number === "string" && number.endsWith(".") ? value : number.toFixed(n),
2459
- unit,
2460
- isString,
2461
- isScientific: isScientificStringNum(value)
2462
- });
2463
- };
2464
- //#endregion
2465
- //#region src/numbers/format/display-number.ts
2466
- const DEFAULT_AUTO_SCIENTIFIC_BELOW = 1e-4;
2467
- const DEFAULT_AUTO_SCIENTIFIC_ABOVE = 1e7;
2468
- const NUMBER_FORMAT_OPTIONS = { maximumFractionDigits: 20 };
2469
- const formatEnglishNumber = (value) => {
2470
- let numberFormat;
2471
- try {
2472
- numberFormat = new Intl.NumberFormat("en-US", NUMBER_FORMAT_OPTIONS);
2473
- } catch {
2474
- numberFormat = new Intl.NumberFormat(void 0, NUMBER_FORMAT_OPTIONS);
2475
- }
2476
- return numberFormat.format(value);
2477
- };
2478
- const superscriptSymbols = {
2479
- "0": "⁰",
2480
- "1": "¹",
2481
- "2": "²",
2482
- "3": "³",
2483
- "4": "⁴",
2484
- "5": "⁵",
2485
- "6": "⁶",
2486
- "7": "⁷",
2487
- "8": "⁸",
2488
- "9": "⁹",
2489
- "+": "⁺",
2490
- "-": "⁻"
2491
- };
2492
- const appendTrailingZeros = (value, numberOfZeros) => {
2493
- const zeros = "0".repeat(numberOfZeros);
2494
- return numberOfZeros > 0 && value !== "0" ? !value.includes(".") ? `${value}.${zeros}` : `${value}${zeros}` : value;
2495
- };
2496
- const formatDecimal = (value, thousandSeparator, preserveTrailingZeros = false) => {
2497
- const convertedValue = formatEnglishNumber(toNum(value)).replaceAll(",", thousandSeparator);
2498
- return preserveTrailingZeros ? appendTrailingZeros(convertedValue, countTrailingZeros(value, true)) : convertedValue;
2499
- };
2500
- const formatDecimalDisplayNumber = (value, options) => {
2501
- const { nonBreakingSpace } = options ?? {};
2502
- if (value === "") return value;
2503
- if (value === null || value === void 0) return "";
2504
- if (!isValidNum(value)) return trim(value.toString());
2505
- return formatDecimal(value, options?.noThousandsSeparator ? "" : nonBreakingSpace ? " " : " ", options?.preserveTrailingZeros);
2506
- };
2507
- const formatScientificDisplayNumber = (value, options) => {
2508
- const { roundScientificCoefficient, eNotation } = options ?? {};
2509
- if (Number.isNaN(value)) return "Invalid";
2510
- if (value === null || value === void 0) return "";
2511
- if (!isValidNum(value) || value === "") return trim(value.toString());
2512
- const sanitizedValue = toNum(value);
2513
- if (!Number.isFinite(sanitizedValue)) return trim(value.toString());
2514
- const power = eNotation ? "e" : "·10";
2515
- const [coefficient, exponent] = sanitizedValue.toExponential().split("e");
2516
- const roundedCoefficient = typeof roundScientificCoefficient === "number" ? round(coefficient, roundScientificCoefficient) : coefficient;
2517
- const noExponent = exponent === "+0" || exponent === "-0";
2518
- const formattedExponent = [...exponent.replaceAll("+", "")].map((c) => eNotation ? c : superscriptSymbols[c]).join("");
2519
- return noExponent ? roundedCoefficient : `${roundedCoefficient}${power}${formattedExponent}`;
2520
- };
2521
- const formatDisplayNumber = (value, options) => {
2522
- const abs = Math.abs(toNum(value));
2523
- return (options?.scientific === "auto" && options?.autoScientificBelow && options?.autoScientificAbove ? abs < options?.autoScientificBelow || abs > options?.autoScientificAbove : options?.scientific) ? formatScientificDisplayNumber(value, options) : formatDecimalDisplayNumber(value, options);
2524
- };
2525
- /**
2526
- * Displays a number with human-friendly formatting (use for non-editable display labels, text)
2527
- *
2528
- * Accepts number types (1.234), stringified numbers ('1.234'), and unit numbers ('1.234|m')
2529
- *
2530
- * @example
2531
- * //returns '1 234.56'
2532
- * displayNumber(1234.56)
2533
- *
2534
- * By default, adds thousands separators. Can be configured to display in scientific notation, and with formatted units.
2535
- *
2536
- * @param value
2537
- * @param options
2538
- * @returns formatted display number
2539
- */
2540
- const displayNumber = (value, options) => {
2541
- const optionsWithDefaults = {
2542
- scientific: options?.scientific ?? "auto",
2543
- eNotation: options?.eNotation ?? false,
2544
- autoScientificBelow: options?.autoScientificBelow ?? DEFAULT_AUTO_SCIENTIFIC_BELOW,
2545
- autoScientificAbove: options?.autoScientificAbove ?? DEFAULT_AUTO_SCIENTIFIC_ABOVE,
2546
- withUnit: options?.withUnit ?? false,
2547
- nonBreakingSpace: options?.nonBreakingSpace ?? false,
2548
- roundScientificCoefficient: options?.roundScientificCoefficient
2549
- };
2550
- const { withUnit } = optionsWithDefaults;
2551
- if (value === null || value === void 0) return "";
2552
- const { number, unit } = parseNumber(value);
2553
- const formattedNumber = formatDisplayNumber(number, optionsWithDefaults);
2554
- const formattedUnit = unit ? LABELS?.[unit] : "";
2555
- return withUnit && unit ? formattedNumber === "" ? formattedUnit : `${formattedNumber} ${formattedUnit}` : formattedNumber;
2556
- };
2557
- /**
2558
- * Displays a number with human-friendly formatting (use for non-editable display labels, text)
2559
- *
2560
- * Accepts number types (1.234), stringified numbers ('1.234'), and unit numbers ('1.234|m')
2561
- *
2562
- * @example
2563
- * //returns '1 234.5600'
2564
- * displayNumberToFixed('1234.5600')
2565
- *
2566
- * By default, adds thousands separators. Can be configured to display in scientific notation, and with formatted units.
2567
- *
2568
- * @param value
2569
- * @param options
2570
- * @returns formatted display number
2571
- */
2572
- const displayNumberToFixed = (value, options) => {
2573
- const optionsWithDefaults = {
2574
- scientific: options?.scientific ?? "auto",
2575
- eNotation: options?.eNotation ?? false,
2576
- autoScientificBelow: options?.autoScientificBelow ?? DEFAULT_AUTO_SCIENTIFIC_BELOW,
2577
- autoScientificAbove: options?.autoScientificAbove ?? DEFAULT_AUTO_SCIENTIFIC_ABOVE,
2578
- withUnit: options?.withUnit ?? false,
2579
- nonBreakingSpace: options?.nonBreakingSpace ?? false,
2580
- roundScientificCoefficient: options?.roundScientificCoefficient
2581
- };
2582
- const { withUnit } = optionsWithDefaults;
2583
- if (value === null || value === void 0) return "";
2584
- const { number, unit } = parseNumber(value, true);
2585
- const formattedNumber = formatDisplayNumber(number, {
2586
- ...optionsWithDefaults,
2587
- preserveTrailingZeros: true
2588
- });
2589
- const formattedUnit = unit ? LABELS?.[unit] : "";
2590
- return withUnit && unit ? formattedNumber === "" ? formattedUnit : `${formattedNumber} ${formattedUnit}` : formattedNumber;
2591
- };
2592
- /** @deprecated Use `displayNumber` instead. */
2593
- const formatNumber = (number) => {
2594
- return displayNumber(number);
2595
- };
2596
- //#endregion
2597
- //#region src/numbers/numbers.ts
2598
- const parseValue = (value) => {
2599
- return typeof value === "string" && isValueWithUnit(value) ? getValue(value) : value;
2600
- };
2601
- /**
2602
- * Checks whether a value can be converted to number type by the toNum() function
2603
- *
2604
- * @param value - value to be checked
2605
- * @returns whether number can be converted by toNum() function
2606
- *
2607
- * @example
2608
- * isValidNum('1 1/2') -> true
2609
- * toNum('foobar|m') -> false
2610
- */
2611
- const isValidNum = (value) => {
2612
- const parsedValue = parseValue(value);
2613
- if (isEmptyString(parsedValue) || Number.isNaN(parsedValue) || parsedValue === Infinity || parsedValue === -Infinity) return true;
2614
- else if (!(isNull(parsedValue) || isUndefined(parsedValue) || isTrailingPeriodSeparator(parsedValue) || isTrailingCommaSeparator(parsedValue) || isArray(parsedValue) || isObject(parsedValue))) {
2615
- const cleanedValue = cleanNumStr(String(parsedValue));
2616
- if (cleanedValue.includes("|")) return false;
2617
- const number = isFraction(cleanedValue) ? numFraction(cleanedValue) : isNumeric(cleanedValue) ? parseFloat(cleanedValue) : cleanedValue;
2618
- if (number === Infinity || number === -Infinity) return true;
2619
- if (!isNumeric(number)) return false;
2620
- if (!Number.isNaN(number)) return true;
2621
- }
2622
- return false;
2623
- };
2624
- /**
2625
- * Checks whether a value is a valid number, in string representation with scientific notation (e.g. '1e3')
2626
- *
2627
- * Note - it's not possible to check whether *number* types are stored in scientific notation (all numbers are stored
2628
- * the same way internally in floating-point formats, so there is no difference between 1000 and 1e3 internally).
2629
- * Whether number types get displayed in scientific notation or not in the console is a browser-specific implementation
2630
- * detail (display formatting) and not something we can check/rely on, so this function is only intended for checking
2631
- * user-input values in string format. See https://stackoverflow.com/a/66005705/942635.
2632
- *
2633
- * @param value - value to be checked
2634
- * @returns whether the value is a valid number in scientific notation
2635
- *
2636
- * @example
2637
- * isValidNum('1e3') -> true
2638
- * toNum(1000) -> false
2639
- * toNum(1e3) -> false (we cannot check scientific notation of number types)
2640
- */
2641
- const isScientificStringNum = (value) => {
2642
- if (typeof value === "string") return isValidNum(value) && value.toLowerCase().includes("e");
2643
- return false;
2644
- };
2645
- /**
2646
- * Converts a numeric value to number type (when possible).
2647
- * - need to know if it's possible first? Call isValidNum()
2648
- * - accepts number types (1.234), stringified numbers ('1.234'), fractions ('1/2'), and unit numbers ('1.234|m')
2649
- * - returns the converted number if possible, otherwise returns the input value or default value when provided
2650
- *
2651
- * @param value - value to be converted to number type
2652
- * @param [fallback] - optional fallback value (returned when not possible to convert)
2653
- * @param [minimum] - optional minimum value
2654
- * @returns valid number after conversion, or fallback, or returns the original input
2655
- *
2656
- * @example
2657
- * toNum('1.2345) -> 1.2345
2658
- * toNum('1.2345|m') -> 1.2345
2659
- */
2660
- const toNum = (value, fallback, minimum) => {
2661
- const fallbackResult = fallback ?? value;
2662
- const parsedValue = parseValue(value);
2663
- if (!isValidNum(parsedValue)) return fallbackResult;
2664
- else {
2665
- const cleanedValue = cleanNumStr(String(parsedValue));
2666
- const number = isFraction(cleanedValue) ? numFraction(cleanedValue) : isNumeric(cleanedValue) ? parseFloat(cleanedValue) : cleanedValue;
2667
- if (number === Infinity || number === -Infinity) return number;
2668
- if (Number.isNaN(number) || !isNumeric(number)) return fallbackResult;
2669
- else if (minimum && number < minimum) return minimum;
2670
- return number;
2671
- }
2672
- };
2673
- /**
2674
- * Convert a number to a string safely, better than String(value)
2675
- * String(0.0000002) returns '2e-7' which is unwanted if we need to preserve formatting
2676
- *
2677
- * @param value
2678
- * @returns number or string output value
2679
- */
2680
- const toString = (value) => {
2681
- if (isValidNum(value)) {
2682
- if (typeof value === "string") return value;
2683
- if (typeof value === "number") {
2684
- if (Number.isNaN(value) || !Number.isFinite(value)) return String(value);
2685
- return formatDecimalDisplayNumber(value, { noThousandsSeparator: true });
2686
- }
2687
- }
2688
- return value;
2689
- };
2690
- //#endregion
2691
- //#region src/validate/ajv-validators.ts
2692
- var import_ucs2length = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((exports) => {
2693
- Object.defineProperty(exports, "__esModule", { value: true });
2694
- function ucs2length(str) {
2695
- const len = str.length;
2696
- let length = 0;
2697
- let pos = 0;
2698
- let value;
2699
- while (pos < len) {
2700
- length++;
2701
- value = str.charCodeAt(pos++);
2702
- if (value >= 55296 && value <= 56319 && pos < len) {
2703
- value = str.charCodeAt(pos);
2704
- if ((value & 64512) === 56320) pos++;
2705
- }
2706
- }
2707
- return length;
2708
- }
2709
- exports.default = ucs2length;
2710
- ucs2length.code = "require(\"ajv/dist/runtime/ucs2length\").default";
2711
- })))(), 1);
2712
- import_ucs2length.default.default ?? import_ucs2length.default;
2713
- const numberSchemaValidator = validate15;
2714
- function validate15(data, { instancePath = "", parentData, parentDataProperty, rootData = data } = {}) {
2715
- validate15.errors = null;
2716
- let vErrors = null;
2717
- let errors = 0;
2718
- if (!(typeof data == "number" && isFinite(data))) {
2719
- const err0 = {
2720
- instancePath,
2721
- schemaPath: "#/type",
2722
- keyword: "type",
2723
- params: { type: "number" },
2724
- message: "must be number"
2725
- };
2726
- if (vErrors === null) vErrors = [err0];
2727
- else vErrors.push(err0);
2728
- errors++;
2729
- }
2730
- if (errors > 0) {
2731
- const emErrs0 = [];
2732
- for (const err1 of vErrors) if (err1.keyword !== "errorMessage" && !err1.emUsed && (err1.instancePath === instancePath || err1.instancePath.indexOf(instancePath) === 0 && err1.instancePath[instancePath.length] === "/") && err1.schemaPath.indexOf("#") === 0 && err1.schemaPath[1] === "/") {
2733
- emErrs0.push(err1);
2734
- err1.emUsed = true;
2735
- }
2736
- if (emErrs0.length) {
2737
- const err2 = {
2738
- instancePath,
2739
- schemaPath: "#/errorMessage",
2740
- keyword: "errorMessage",
2741
- params: { errors: emErrs0 },
2742
- message: "Must be a numerical value"
2743
- };
2744
- if (vErrors === null) vErrors = [err2];
2745
- else vErrors.push(err2);
2746
- errors++;
2747
- }
2748
- const emErrs1 = [];
2749
- for (const err3 of vErrors) if (!err3.emUsed) emErrs1.push(err3);
2750
- vErrors = emErrs1;
2751
- errors = emErrs1.length;
2752
- }
2753
- validate15.errors = vErrors;
2754
- return errors === 0;
2755
- }
2756
- //#endregion
2757
- //#region src/validate/errors-transform.ts
2758
- const transformErrors = (errors) => {
2759
- return errors?.map(({ message }) => message);
2760
- };
2761
- //#endregion
2762
- //#region src/units/validation.ts
2763
- /** Normalizes repeated decimal dots and decimal commas. */
2764
- function checkAndCleanDecimalComma(value) {
2765
- const repeatedDots = /\.{2,}/;
2766
- const comma = /,/;
2767
- if (typeof value === "string") while (repeatedDots.test(value) || comma.test(value)) {
2768
- value = value.replace(repeatedDots, ".");
2769
- value = value.replace(comma, ".");
2770
- }
2771
- return value;
2772
- }
2773
- /** Cleans raw numeric input while retaining the unit from the previous value. */
2774
- function validateAndClean(previousValue, nextText) {
2775
- const unit = split(previousValue)[1];
2776
- const cleanedValue = nextText.replace(/[^0-9.,-Ee]/g, "").replace(/^([^(e|E)]*[eE])|[eE]/g, "$1").replace(/^[E|e]*|[E|e]*$/g, "").replace(/,/g, ".").replace(/^([^.]*\.)|\./g, "$1").replace(/\.(?=e)/g, "").replace(/-|[eE]-/g, (match, offset) => offset === 0 || match.toLowerCase() === "e-" ? match : "");
2777
- return !Number.isFinite(+cleanedValue) ? previousValue : `${cleanedValue}${unit ? "|" : ""}${unit}`;
2778
- }
2779
- /** Validates a numeric or unit-encoded value against the package number schema. */
2780
- function validateNumber(value) {
2781
- let normalizedValue = value;
2782
- if (typeof value === "string" && isValueWithUnit(value)) normalizedValue = getValue(value);
2783
- normalizedValue = checkAndCleanDecimalComma(normalizedValue);
2784
- if (isNumeric(normalizedValue)) return {
2785
- valid: numberSchemaValidator(toNum(normalizedValue)),
2786
- errors: transformErrors(numberSchemaValidator.errors)
2787
- };
2788
- return {
2789
- valid: numberSchemaValidator(normalizedValue),
2790
- errors: transformErrors(numberSchemaValidator.errors)
2791
- };
2792
- }
2793
- //#endregion
2794
- //#region src/units/conversion.ts
2795
- /** Converts a numeric value between compatible units. */
2796
- function to(value, fromUnit, toUnit) {
2797
- value = checkAndCleanDecimalComma(value);
2798
- value = normalizeScientific(value);
2799
- if (toUnit === "undefined") console.warn("Inconsistent \"to unit\" - debug call to \"Units.to()\"");
2800
- if (fromUnit === "undefined") {
2801
- fromUnit = toUnit;
2802
- console.warn("Inconsistent \"from unit\" - debug call to \"Units.to()\"");
2803
- }
2804
- if (fromUnit === toUnit) return toNum(value);
2805
- if (value === Infinity || value === "Infinity") return Infinity;
2806
- if (value === -Infinity || value === "-Infinity") return -Infinity;
2807
- if (isNonNumerical(value) && value !== "") return NaN;
2808
- const conversion = KNOWN_CONVERSIONS[`${fromUnit}|${toUnit}`];
2809
- if (conversion) return conversion(toNum(value));
2810
- if (DEPRECATED_UNITS[fromUnit]) {
2811
- console.warn(`Unit '${fromUnit}' is deprecated - use '${DEPRECATED_UNITS[fromUnit]}' instead.`);
2812
- return to(value, DEPRECATED_UNITS[fromUnit], toUnit);
2813
- }
2814
- if (DEPRECATED_UNITS[toUnit]) {
2815
- console.warn(`Unit '${toUnit}' is deprecated - use '${DEPRECATED_UNITS[toUnit]}' instead.`);
2816
- return to(value, fromUnit, DEPRECATED_UNITS[toUnit]);
2817
- }
2818
- if (UNIT_ALIASES[toUnit]) return to(value, fromUnit, UNIT_ALIASES[toUnit]);
2819
- if (UNIT_ALIASES[fromUnit]) return to(value, UNIT_ALIASES[fromUnit], toUnit);
2820
- const intermediateFromUnit = INTERMEDIATE_CONVERSIONS[fromUnit];
2821
- if (intermediateFromUnit) return to(to(value, fromUnit, intermediateFromUnit), intermediateFromUnit, toUnit);
2822
- const intermediateToUnit = INTERMEDIATE_CONVERSIONS[toUnit];
2823
- if (toUnit && intermediateToUnit && intermediateToUnit !== toUnit) return to(to(value, fromUnit, intermediateToUnit), intermediateToUnit, toUnit);
2824
- console.error("no conversions found", value, fromUnit, "->", toUnit);
2825
- throw new Error(`No conversions found: ${value} ${fromUnit} -> ${toUnit}`);
2826
- }
2827
- /** Converts a value with an optional unit suffix to the requested unit. */
2828
- function unum(valueWithUnit, toUnit, fromUnit) {
2829
- if (valueWithUnit == null || valueWithUnit === "") return 0;
2830
- if (typeof valueWithUnit === "string" && valueWithUnit.startsWith("NaN") || typeof valueWithUnit === "number" && isNaN(valueWithUnit)) return NaN;
2831
- const parts = split(cleanNumStr(normalizeScientific(valueWithUnit)).replaceAll("+", ""));
2832
- if (!parts) {
2833
- if (toUnit && fromUnit) return unum(valueWithUnit + fromUnit, toUnit);
2834
- throw new Error(`unum: invalid number: ${valueWithUnit}`);
2835
- }
2836
- if (parts[0] == null) parts[0] = "0";
2837
- if (parts[1]) fromUnit = parts[1];
2838
- if (!fromUnit && toUnit !== fromUnit) throw new Error(`unum: unable to figure out unit: ${valueWithUnit} fromUnit ${fromUnit}`);
2839
- if (toUnit === fromUnit) {
2840
- const value = parts[0] ? toNum(parts[0]) : 0;
2841
- if (value === Infinity || value === "Infinity") return Infinity;
2842
- if (value === -Infinity || value === "-Infinity") return -Infinity;
2843
- if (typeof value === "string" && EXP_NOTATION_RE.test(value)) return parseFloat(value);
2844
- if (!isNumeric(value) && value !== Infinity && value !== -Infinity) throw new Error(`unum: invalid number: ${value}, ${typeof value}`);
2845
- return cleanNum(value);
2846
- }
2847
- return to(parts[0], fromUnit, toUnit);
2848
- }
2849
- /** Alias for `unum`. */
2850
- function convertAndGetValue(value, toUnit, fromUnit) {
2851
- return unum(value, toUnit, fromUnit);
2852
- }
2853
- /** Converts a value while preserving string types and empty values. */
2854
- function convertAndGetValueStrict(value, toUnit, fromUnit) {
2855
- if (value === "" || value === null) return value;
2856
- if (typeof value === "string" && isValueWithUnit(value) && getValue(value) === "") return "";
2857
- const isString = typeof value === "string";
2858
- const result = convertAndGetValue(value, toUnit, fromUnit);
2859
- return isString ? toString(result) : result;
2860
- }
2861
- /** Converts a value to the base unit configured for a quantity. */
2862
- function toBase(value, quantity) {
2863
- const baseUnit = unitFromKey(quantity);
2864
- return unum(value, baseUnit, split((value || "").toString())[1] || baseUnit);
2865
- }
2866
- /** Converts a value and appends the requested unit. */
2867
- function unumWithUnit(value, toUnit, fromUnit) {
2868
- return withUnit(unum(value, toUnit, fromUnit), toUnit);
2869
- }
2870
- /** Converts a unit value while retaining approximately the input precision. */
2871
- function convertSamePrecision(valueWithUnit, toUnit, digits) {
2872
- const validValueWithUnit = String(valueWithUnit);
2873
- const parts = split(validValueWithUnit);
2874
- const convertedNumber = !parts[1] || parts[1] == toUnit ? Number(parts[0]) : to(parts[0], String(parts[1]), toUnit);
2875
- let prettyNumber = "0";
2876
- let targetDigits = digits;
2877
- if (convertedNumber !== 0) {
2878
- if (!targetDigits) {
2879
- if (parts[1] === toUnit) return validValueWithUnit;
2880
- const digitParts = String(parts[0]).match(/^[-+.,0]*(\d*)[.,]?(\d*)/);
2881
- targetDigits = digitParts ? Math.max(3, digitParts[1].length + digitParts[2].length) : 3;
2882
- }
2883
- const limit = Math.pow(10, --targetDigits);
2884
- const absoluteNumber = Math.abs(convertedNumber);
2885
- if (absoluteNumber >= 1e5 * limit || absoluteNumber * 1e4 * (1 + limit) < limit) prettyNumber = convertedNumber.toExponential(targetDigits);
2886
- else if (absoluteNumber >= limit) prettyNumber = convertedNumber.toFixed();
2887
- else {
2888
- const magnitude = Math.floor(Math.log10(absoluteNumber));
2889
- prettyNumber = convertedNumber.toFixed(targetDigits - magnitude);
2890
- let index = prettyNumber.length;
2891
- if (prettyNumber[--index] == "0") {
2892
- while (prettyNumber[--index] == "0");
2893
- prettyNumber = prettyNumber.slice(0, index + (prettyNumber[index] == "." ? 0 : 1));
2894
- }
2895
- }
2896
- }
2897
- return withUnit(prettyNumber, toUnit);
2898
- }
2899
- //#endregion
2900
- Object.defineProperty(exports, "ALT_UNITS", {
2901
- enumerable: true,
2902
- get: function() {
2903
- return ALT_UNITS;
2904
- }
2905
- });
2906
- Object.defineProperty(exports, "DEPRECATED_UNITS", {
2907
- enumerable: true,
2908
- get: function() {
2909
- return DEPRECATED_UNITS;
2910
- }
2911
- });
2912
- Object.defineProperty(exports, "EXP_NOTATION_RE", {
2913
- enumerable: true,
2914
- get: function() {
2915
- return EXP_NOTATION_RE;
2916
- }
2917
- });
2918
- Object.defineProperty(exports, "INTERMEDIATE_CONVERSIONS", {
2919
- enumerable: true,
2920
- get: function() {
2921
- return INTERMEDIATE_CONVERSIONS;
2922
- }
2923
- });
2924
- Object.defineProperty(exports, "KNOWN_CONVERSIONS", {
2925
- enumerable: true,
2926
- get: function() {
2927
- return KNOWN_CONVERSIONS;
2928
- }
2929
- });
2930
- Object.defineProperty(exports, "KNOWN_UNITS", {
2931
- enumerable: true,
2932
- get: function() {
2933
- return KNOWN_UNITS;
2934
- }
2935
- });
2936
- Object.defineProperty(exports, "LABELS", {
2937
- enumerable: true,
2938
- get: function() {
2939
- return LABELS;
2940
- }
2941
- });
2942
- Object.defineProperty(exports, "QUANTITIES_DESCRIPTION", {
2943
- enumerable: true,
2944
- get: function() {
2945
- return QUANTITIES_DESCRIPTION;
2946
- }
2947
- });
2948
- Object.defineProperty(exports, "SEPARATOR", {
2949
- enumerable: true,
2950
- get: function() {
2951
- return SEPARATOR;
2952
- }
2953
- });
2954
- Object.defineProperty(exports, "UNITS_DESCRIPTION", {
2955
- enumerable: true,
2956
- get: function() {
2957
- return UNITS_DESCRIPTION;
2958
- }
2959
- });
2960
- Object.defineProperty(exports, "UNIT_ALIASES", {
2961
- enumerable: true,
2962
- get: function() {
2963
- return UNIT_ALIASES;
2964
- }
2965
- });
2966
- Object.defineProperty(exports, "UNIT_FROM_KEY", {
2967
- enumerable: true,
2968
- get: function() {
2969
- return UNIT_FROM_KEY;
2970
- }
2971
- });
2972
- Object.defineProperty(exports, "allNumbers", {
2973
- enumerable: true,
2974
- get: function() {
2975
- return allNumbers;
2976
- }
2977
- });
2978
- Object.defineProperty(exports, "asFraction", {
2979
- enumerable: true,
2980
- get: function() {
2981
- return asFraction;
2982
- }
2983
- });
2984
- Object.defineProperty(exports, "charCount", {
2985
- enumerable: true,
2986
- get: function() {
2987
- return charCount;
2988
- }
2989
- });
2990
- Object.defineProperty(exports, "checkAndCleanDecimalComma", {
2991
- enumerable: true,
2992
- get: function() {
2993
- return checkAndCleanDecimalComma;
2994
- }
2995
- });
2996
- Object.defineProperty(exports, "cleanNum", {
2997
- enumerable: true,
2998
- get: function() {
2999
- return cleanNum;
3000
- }
3001
- });
3002
- Object.defineProperty(exports, "cleanNumStr", {
3003
- enumerable: true,
3004
- get: function() {
3005
- return cleanNumStr;
3006
- }
3007
- });
3008
- Object.defineProperty(exports, "convertAndGetValue", {
3009
- enumerable: true,
3010
- get: function() {
3011
- return convertAndGetValue;
3012
- }
3013
- });
3014
- Object.defineProperty(exports, "convertAndGetValueStrict", {
3015
- enumerable: true,
3016
- get: function() {
3017
- return convertAndGetValueStrict;
3018
- }
3019
- });
3020
- Object.defineProperty(exports, "convertSamePrecision", {
3021
- enumerable: true,
3022
- get: function() {
3023
- return convertSamePrecision;
3024
- }
3025
- });
3026
- Object.defineProperty(exports, "displayNumber", {
3027
- enumerable: true,
3028
- get: function() {
3029
- return displayNumber;
3030
- }
3031
- });
3032
- Object.defineProperty(exports, "displayNumberToFixed", {
3033
- enumerable: true,
3034
- get: function() {
3035
- return displayNumberToFixed;
3036
- }
3037
- });
3038
- Object.defineProperty(exports, "formatNumber", {
3039
- enumerable: true,
3040
- get: function() {
3041
- return formatNumber;
3042
- }
3043
- });
3044
- Object.defineProperty(exports, "fraction", {
3045
- enumerable: true,
3046
- get: function() {
3047
- return fraction;
3048
- }
3049
- });
3050
- Object.defineProperty(exports, "getAltUnitsListByQuantity", {
3051
- enumerable: true,
3052
- get: function() {
3053
- return getAltUnitsListByQuantity;
3054
- }
3055
- });
3056
- Object.defineProperty(exports, "getQuantities", {
3057
- enumerable: true,
3058
- get: function() {
3059
- return getQuantities;
3060
- }
3061
- });
3062
- Object.defineProperty(exports, "getUnit", {
3063
- enumerable: true,
3064
- get: function() {
3065
- return getUnit;
3066
- }
3067
- });
3068
- Object.defineProperty(exports, "getUnitsForQuantity", {
3069
- enumerable: true,
3070
- get: function() {
3071
- return getUnitsForQuantity;
3072
- }
3073
- });
3074
- Object.defineProperty(exports, "getValue", {
3075
- enumerable: true,
3076
- get: function() {
3077
- return getValue;
3078
- }
3079
- });
3080
- Object.defineProperty(exports, "isCloseTo", {
3081
- enumerable: true,
3082
- get: function() {
3083
- return isCloseTo;
3084
- }
3085
- });
3086
- Object.defineProperty(exports, "isCloseToOrGreaterThan", {
3087
- enumerable: true,
3088
- get: function() {
3089
- return isCloseToOrGreaterThan;
3090
- }
3091
- });
3092
- Object.defineProperty(exports, "isCloseToOrLessThan", {
3093
- enumerable: true,
3094
- get: function() {
3095
- return isCloseToOrLessThan;
3096
- }
3097
- });
3098
- Object.defineProperty(exports, "isDeepCloseTo", {
3099
- enumerable: true,
3100
- get: function() {
3101
- return isDeepCloseTo;
3102
- }
3103
- });
3104
- Object.defineProperty(exports, "isEmptyValueWithUnit", {
3105
- enumerable: true,
3106
- get: function() {
3107
- return isEmptyValueWithUnit;
3108
- }
3109
- });
3110
- Object.defineProperty(exports, "isFraction", {
3111
- enumerable: true,
3112
- get: function() {
3113
- return isFraction;
3114
- }
3115
- });
3116
- Object.defineProperty(exports, "isNonNumerical", {
3117
- enumerable: true,
3118
- get: function() {
3119
- return isNonNumerical;
3120
- }
3121
- });
3122
- Object.defineProperty(exports, "isNumeric", {
3123
- enumerable: true,
3124
- get: function() {
3125
- return isNumeric;
3126
- }
3127
- });
3128
- Object.defineProperty(exports, "isScientificStringNum", {
3129
- enumerable: true,
3130
- get: function() {
3131
- return isScientificStringNum;
3132
- }
3133
- });
3134
- Object.defineProperty(exports, "isValidNum", {
3135
- enumerable: true,
3136
- get: function() {
3137
- return isValidNum;
3138
- }
3139
- });
3140
- Object.defineProperty(exports, "isValueWithUnit", {
3141
- enumerable: true,
3142
- get: function() {
3143
- return isValueWithUnit;
3144
- }
3145
- });
3146
- Object.defineProperty(exports, "label", {
3147
- enumerable: true,
3148
- get: function() {
3149
- return label;
3150
- }
3151
- });
3152
- Object.defineProperty(exports, "numFraction", {
3153
- enumerable: true,
3154
- get: function() {
3155
- return numFraction;
3156
- }
3157
- });
3158
- Object.defineProperty(exports, "round", {
3159
- enumerable: true,
3160
- get: function() {
3161
- return round;
3162
- }
3163
- });
3164
- Object.defineProperty(exports, "roundByMagnitude", {
3165
- enumerable: true,
3166
- get: function() {
3167
- return roundByMagnitude;
3168
- }
3169
- });
3170
- Object.defineProperty(exports, "roundByMagnitudeToFixed", {
3171
- enumerable: true,
3172
- get: function() {
3173
- return roundByMagnitudeToFixed;
3174
- }
3175
- });
3176
- Object.defineProperty(exports, "roundByRange", {
3177
- enumerable: true,
3178
- get: function() {
3179
- return roundByRange;
3180
- }
3181
- });
3182
- Object.defineProperty(exports, "roundToDecimalPrecision", {
3183
- enumerable: true,
3184
- get: function() {
3185
- return roundToDecimalPrecision;
3186
- }
3187
- });
3188
- Object.defineProperty(exports, "roundToFixed", {
3189
- enumerable: true,
3190
- get: function() {
3191
- return roundToFixed;
3192
- }
3193
- });
3194
- Object.defineProperty(exports, "roundToPrecision", {
3195
- enumerable: true,
3196
- get: function() {
3197
- return roundToPrecision;
3198
- }
3199
- });
3200
- Object.defineProperty(exports, "showAltUnitsList", {
3201
- enumerable: true,
3202
- get: function() {
3203
- return showAltUnitsList;
3204
- }
3205
- });
3206
- Object.defineProperty(exports, "split", {
3207
- enumerable: true,
3208
- get: function() {
3209
- return split;
3210
- }
3211
- });
3212
- Object.defineProperty(exports, "stripLeadingZeros", {
3213
- enumerable: true,
3214
- get: function() {
3215
- return stripLeadingZeros;
3216
- }
3217
- });
3218
- Object.defineProperty(exports, "to", {
3219
- enumerable: true,
3220
- get: function() {
3221
- return to;
3222
- }
3223
- });
3224
- Object.defineProperty(exports, "toBase", {
3225
- enumerable: true,
3226
- get: function() {
3227
- return toBase;
3228
- }
3229
- });
3230
- Object.defineProperty(exports, "toNum", {
3231
- enumerable: true,
3232
- get: function() {
3233
- return toNum;
3234
- }
3235
- });
3236
- Object.defineProperty(exports, "toString", {
3237
- enumerable: true,
3238
- get: function() {
3239
- return toString;
3240
- }
3241
- });
3242
- Object.defineProperty(exports, "unitFromKey", {
3243
- enumerable: true,
3244
- get: function() {
3245
- return unitFromKey;
3246
- }
3247
- });
3248
- Object.defineProperty(exports, "unitFromQuantity", {
3249
- enumerable: true,
3250
- get: function() {
3251
- return unitFromQuantity;
3252
- }
3253
- });
3254
- Object.defineProperty(exports, "unum", {
3255
- enumerable: true,
3256
- get: function() {
3257
- return unum;
3258
- }
3259
- });
3260
- Object.defineProperty(exports, "unumWithUnit", {
3261
- enumerable: true,
3262
- get: function() {
3263
- return unumWithUnit;
3264
- }
3265
- });
3266
- Object.defineProperty(exports, "validateAndClean", {
3267
- enumerable: true,
3268
- get: function() {
3269
- return validateAndClean;
3270
- }
3271
- });
3272
- Object.defineProperty(exports, "validateNumber", {
3273
- enumerable: true,
3274
- get: function() {
3275
- return validateNumber;
3276
- }
3277
- });
3278
- Object.defineProperty(exports, "withPrettyUnitLabel", {
3279
- enumerable: true,
3280
- get: function() {
3281
- return withPrettyUnitLabel;
3282
- }
3283
- });
3284
- Object.defineProperty(exports, "withUnit", {
3285
- enumerable: true,
3286
- get: function() {
3287
- return withUnit;
3288
- }
3289
- });
3290
-
3291
- //# sourceMappingURL=conversion.cjs.map