@aguacerowx/javascript-sdk 0.0.28 → 0.0.29

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,5 +1,5 @@
1
- export function spawnGridDecodeWorker() {
2
- return new Worker(new URL('./gridDecodeWorker.js', import.meta.url), {
3
- type: 'module',
4
- });
5
- }
1
+ export function spawnGridDecodeWorker() {
2
+ return new Worker(new URL('./gridDecodeWorker.js', import.meta.url), {
3
+ type: 'module',
4
+ });
5
+ }
@@ -1,103 +1,103 @@
1
- /**
2
- * A utility module for converting between different physical units.
3
- * Contains a comprehensive object of conversion functions and a helper
4
- * to retrieve the correct function based on unit names.
5
- */
6
-
7
- // The main object containing all the raw conversion functions.
8
- export const unitConversions = {
9
- kelvin_to_celsius: (data) => data - 273.15,
10
- kelvin_to_fahrenheit: (data) => (data - 273.15) * 9/5 + 32,
11
- kelvin_to_c: (data) => data - 273.15,
12
- kelvin_to_f: (data) => (data - 273.15) * 9/5 + 32,
13
- k_to_celsius: (data) => data - 273.15,
14
- k_to_fahrenheit: (data) => (data - 273.15) * 9/5 + 32,
15
- k_to_c: (data) => data - 273.15,
16
- k_to_f: (data) => (data - 273.15) * 9/5 + 32,
17
- celsius_to_fahrenheit: (data) => (data * 9/5) + 32,
18
- celsius_to_f: (data) => (data * 9/5) + 32,
19
- c_to_fahrenheit: (data) => (data * 9/5) + 32,
20
- c_to_f: (data) => (data * 9/5) + 32,
21
- fahrenheit_to_celsius: (data) => (data - 32) * 5/9,
22
- fahrenheit_to_c: (data) => (data - 32) * 5/9,
23
- f_to_celsius: (data) => (data - 32) * 5/9,
24
- f_to_c: (data) => (data - 32) * 5/9,
25
- meters_to_feet: (data) => data * 3.28084,
26
- meters_to_km: (data) => data / 1000,
27
- m_to_feet: (data) => data * 3.28084,
28
- m_to_ft: (data) => data * 3.28084,
29
- m_to_km: (data) => data / 1000,
30
- kts_to_mph: (data) => data * 1.15078,
31
- mph_to_kts: (data) => data / 1.15078,
32
- kts_to_ms: (data) => data / 1.94384449,
33
- mph_to_ms: (data) => data / 2.23693629,
34
- ms_to_mph: (data) => data * 2.23694,
35
- ms_to_kts: (data) => data * 1.94384,
36
- kts_to_kmh: (data) => data * 1.852,
37
- mph_to_kmh: (data) => data * 1.60934,
38
- ms_to_kmh: (data) => data * 3.6,
39
- kmh_to_kts: (data) => data / 1.852,
40
- kmh_to_mph: (data) => data / 1.60934,
41
- kmh_to_ms: (data) => data / 3.6,
42
- inches_to_mm: (data) => data * 25.4,
43
- inches_to_cm: (data) => data * 2.54,
44
- in_to_mm: (data) => data * 25.4,
45
- in_to_cm: (data) => data * 2.54,
46
- mm_to_in: (data) => data / 25.4,
47
- mm_to_inches: (data) => data / 25.4,
48
- cm_to_in: (data) => data / 2.54,
49
- cm_to_inches: (data) => data / 2.54,
50
- inhr_to_mmhr: (data) => data * 25.4,
51
- inhr_to_cmhr: (data) => data * 2.54,
52
- in_hr_to_mm_hr: (data) => data * 25.4,
53
- in_hr_to_cm_hr: (data) => data * 2.54,
54
- mmhr_to_inhr: (data) => data / 25.4,
55
- cmhr_to_inhr: (data) => data / 2.54,
56
- mm_hr_to_in_hr: (data) => data / 25.4,
57
- cm_hr_to_in_hr: (data) => data / 2.54,
58
- mmhr_to_cmhr: (data) => data / 10,
59
- cmhr_to_mmhr: (data) => data * 10,
60
- mm_hr_to_cm_hr: (data) => data / 10,
61
- cm_hr_to_mm_hr: (data) => data * 10
62
- };
63
-
64
- /**
65
- * Finds and returns the correct conversion function based on "from" and "to" unit strings.
66
- * It normalizes common unit abbreviations to a consistent key.
67
- * @param {string} fromUnit - The starting unit (e.g., 'kelvin', '°C', 'kts').
68
- * @param {string} toUnit - The target unit (e.g., 'fahrenheit', '°F', 'mph').
69
- * @returns {function(number): number | null} The conversion function, or null if not found.
70
- */
71
- export function getUnitConversionFunction(fromUnit, toUnit) {
72
- // A map to standardize various unit string formats to a single key format.
73
- const unitMap = {
74
- '°c': 'c', '°f': 'f', '°k': 'k',
75
- 'celsius': 'c', 'fahrenheit': 'f', 'kelvin': 'k',
76
- 'c': 'c', 'f': 'f', 'k': 'k', '°F': 'f', '°C': 'c',
77
- 'kts': 'kts', 'm/s': 'ms', 'mph': 'mph', 'km/h': 'kmh',
78
- 'knots': 'kts',
79
- 'ft': 'ft', 'feet': 'ft',
80
- 'km': 'km',
81
- 'mm': 'mm',
82
- 'cm': 'cm',
83
- 'm': 'm', 'meters': 'm',
84
- 'in/hr': 'inhr', 'mm/hr': 'mmhr', 'cm/hr': 'cmhr',
85
- 'in': 'in', 'inches': 'in'
86
- };
87
-
88
- // Cleans and standardizes the input unit string.
89
- const normalizeUnit = (unit) => {
90
- if (!unit) return '';
91
- const lowerUnit = unit.toLowerCase().trim();
92
- return unitMap[lowerUnit] || lowerUnit;
93
- };
94
-
95
- const fromNormalized = normalizeUnit(fromUnit);
96
- const toNormalized = normalizeUnit(toUnit);
97
-
98
- // Constructs the key to look up in the `unitConversions` object (e.g., 'k_to_f').
99
- const conversionKey = `${fromNormalized}_to_${toNormalized}`;
100
-
101
- // Return the function if it exists, otherwise return null.
102
- return unitConversions[conversionKey] || null;
1
+ /**
2
+ * A utility module for converting between different physical units.
3
+ * Contains a comprehensive object of conversion functions and a helper
4
+ * to retrieve the correct function based on unit names.
5
+ */
6
+
7
+ // The main object containing all the raw conversion functions.
8
+ export const unitConversions = {
9
+ kelvin_to_celsius: (data) => data - 273.15,
10
+ kelvin_to_fahrenheit: (data) => (data - 273.15) * 9/5 + 32,
11
+ kelvin_to_c: (data) => data - 273.15,
12
+ kelvin_to_f: (data) => (data - 273.15) * 9/5 + 32,
13
+ k_to_celsius: (data) => data - 273.15,
14
+ k_to_fahrenheit: (data) => (data - 273.15) * 9/5 + 32,
15
+ k_to_c: (data) => data - 273.15,
16
+ k_to_f: (data) => (data - 273.15) * 9/5 + 32,
17
+ celsius_to_fahrenheit: (data) => (data * 9/5) + 32,
18
+ celsius_to_f: (data) => (data * 9/5) + 32,
19
+ c_to_fahrenheit: (data) => (data * 9/5) + 32,
20
+ c_to_f: (data) => (data * 9/5) + 32,
21
+ fahrenheit_to_celsius: (data) => (data - 32) * 5/9,
22
+ fahrenheit_to_c: (data) => (data - 32) * 5/9,
23
+ f_to_celsius: (data) => (data - 32) * 5/9,
24
+ f_to_c: (data) => (data - 32) * 5/9,
25
+ meters_to_feet: (data) => data * 3.28084,
26
+ meters_to_km: (data) => data / 1000,
27
+ m_to_feet: (data) => data * 3.28084,
28
+ m_to_ft: (data) => data * 3.28084,
29
+ m_to_km: (data) => data / 1000,
30
+ kts_to_mph: (data) => data * 1.15078,
31
+ mph_to_kts: (data) => data / 1.15078,
32
+ kts_to_ms: (data) => data / 1.94384449,
33
+ mph_to_ms: (data) => data / 2.23693629,
34
+ ms_to_mph: (data) => data * 2.23694,
35
+ ms_to_kts: (data) => data * 1.94384,
36
+ kts_to_kmh: (data) => data * 1.852,
37
+ mph_to_kmh: (data) => data * 1.60934,
38
+ ms_to_kmh: (data) => data * 3.6,
39
+ kmh_to_kts: (data) => data / 1.852,
40
+ kmh_to_mph: (data) => data / 1.60934,
41
+ kmh_to_ms: (data) => data / 3.6,
42
+ inches_to_mm: (data) => data * 25.4,
43
+ inches_to_cm: (data) => data * 2.54,
44
+ in_to_mm: (data) => data * 25.4,
45
+ in_to_cm: (data) => data * 2.54,
46
+ mm_to_in: (data) => data / 25.4,
47
+ mm_to_inches: (data) => data / 25.4,
48
+ cm_to_in: (data) => data / 2.54,
49
+ cm_to_inches: (data) => data / 2.54,
50
+ inhr_to_mmhr: (data) => data * 25.4,
51
+ inhr_to_cmhr: (data) => data * 2.54,
52
+ in_hr_to_mm_hr: (data) => data * 25.4,
53
+ in_hr_to_cm_hr: (data) => data * 2.54,
54
+ mmhr_to_inhr: (data) => data / 25.4,
55
+ cmhr_to_inhr: (data) => data / 2.54,
56
+ mm_hr_to_in_hr: (data) => data / 25.4,
57
+ cm_hr_to_in_hr: (data) => data / 2.54,
58
+ mmhr_to_cmhr: (data) => data / 10,
59
+ cmhr_to_mmhr: (data) => data * 10,
60
+ mm_hr_to_cm_hr: (data) => data / 10,
61
+ cm_hr_to_mm_hr: (data) => data * 10
62
+ };
63
+
64
+ /**
65
+ * Finds and returns the correct conversion function based on "from" and "to" unit strings.
66
+ * It normalizes common unit abbreviations to a consistent key.
67
+ * @param {string} fromUnit - The starting unit (e.g., 'kelvin', '°C', 'kts').
68
+ * @param {string} toUnit - The target unit (e.g., 'fahrenheit', '°F', 'mph').
69
+ * @returns {function(number): number | null} The conversion function, or null if not found.
70
+ */
71
+ export function getUnitConversionFunction(fromUnit, toUnit) {
72
+ // A map to standardize various unit string formats to a single key format.
73
+ const unitMap = {
74
+ '°c': 'c', '°f': 'f', '°k': 'k',
75
+ 'celsius': 'c', 'fahrenheit': 'f', 'kelvin': 'k',
76
+ 'c': 'c', 'f': 'f', 'k': 'k', '°F': 'f', '°C': 'c',
77
+ 'kts': 'kts', 'm/s': 'ms', 'mph': 'mph', 'km/h': 'kmh',
78
+ 'knots': 'kts',
79
+ 'ft': 'ft', 'feet': 'ft',
80
+ 'km': 'km',
81
+ 'mm': 'mm',
82
+ 'cm': 'cm',
83
+ 'm': 'm', 'meters': 'm',
84
+ 'in/hr': 'inhr', 'mm/hr': 'mmhr', 'cm/hr': 'cmhr',
85
+ 'in': 'in', 'inches': 'in'
86
+ };
87
+
88
+ // Cleans and standardizes the input unit string.
89
+ const normalizeUnit = (unit) => {
90
+ if (!unit) return '';
91
+ const lowerUnit = unit.toLowerCase().trim();
92
+ return unitMap[lowerUnit] || lowerUnit;
93
+ };
94
+
95
+ const fromNormalized = normalizeUnit(fromUnit);
96
+ const toNormalized = normalizeUnit(toUnit);
97
+
98
+ // Constructs the key to look up in the `unitConversions` object (e.g., 'k_to_f').
99
+ const conversionKey = `${fromNormalized}_to_${toNormalized}`;
100
+
101
+ // Return the function if it exists, otherwise return null.
102
+ return unitConversions[conversionKey] || null;
103
103
  }