@garmin/fitsdk 21.169.0 → 21.170.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@garmin/fitsdk",
3
- "version": "21.169.0",
3
+ "version": "21.170.0",
4
4
  "description": "FIT JavaScript SDK",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -5,8 +5,8 @@
5
5
  // Transfer (FIT) Protocol License.
6
6
  /////////////////////////////////////////////////////////////////////////////////////////////
7
7
  // ****WARNING**** This file is auto-generated! Do NOT edit this file.
8
- // Profile Version = 21.169.0Release
9
- // Tag = production/release/21.169.0-0-g7105132
8
+ // Profile Version = 21.170.0Release
9
+ // Tag = production/release/21.170.0-0-g5991e72
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
package/src/bit-stream.js CHANGED
@@ -5,8 +5,8 @@
5
5
  // Transfer (FIT) Protocol License.
6
6
  /////////////////////////////////////////////////////////////////////////////////////////////
7
7
  // ****WARNING**** This file is auto-generated! Do NOT edit this file.
8
- // Profile Version = 21.169.0Release
9
- // Tag = production/release/21.169.0-0-g7105132
8
+ // Profile Version = 21.170.0Release
9
+ // Tag = production/release/21.170.0-0-g5991e72
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
@@ -5,8 +5,8 @@
5
5
  // Transfer (FIT) Protocol License.
6
6
  /////////////////////////////////////////////////////////////////////////////////////////////
7
7
  // ****WARNING**** This file is auto-generated! Do NOT edit this file.
8
- // Profile Version = 21.169.0Release
9
- // Tag = production/release/21.169.0-0-g7105132
8
+ // Profile Version = 21.170.0Release
9
+ // Tag = production/release/21.170.0-0-g5991e72
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
package/src/decoder.js CHANGED
@@ -5,8 +5,8 @@
5
5
  // Transfer (FIT) Protocol License.
6
6
  /////////////////////////////////////////////////////////////////////////////////////////////
7
7
  // ****WARNING**** This file is auto-generated! Do NOT edit this file.
8
- // Profile Version = 21.169.0Release
9
- // Tag = production/release/21.169.0-0-g7105132
8
+ // Profile Version = 21.170.0Release
9
+ // Tag = production/release/21.170.0-0-g5991e72
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
package/src/encoder.js CHANGED
@@ -5,8 +5,8 @@
5
5
  // Transfer (FIT) Protocol License.
6
6
  /////////////////////////////////////////////////////////////////////////////////////////////
7
7
  // ****WARNING**** This file is auto-generated! Do NOT edit this file.
8
- // Profile Version = 21.169.0Release
9
- // Tag = production/release/21.169.0-0-g7105132
8
+ // Profile Version = 21.170.0Release
9
+ // Tag = production/release/21.170.0-0-g5991e72
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
@@ -20,6 +20,9 @@ import Utils from "./utils.js";
20
20
  const HEADER_WITH_CRC_SIZE = 14;
21
21
  const HEADER_WITHOUT_CRC_SIZE = 12;
22
22
 
23
+ const FIELD_DEFAULT_SCALE = 1;
24
+ const FIELD_DEFAULT_OFFSET = 0;
25
+
23
26
  /**
24
27
  * A class for encoding FIT files.
25
28
  * @class
@@ -212,10 +215,17 @@ class Encoder {
212
215
  throw new Error();
213
216
  }
214
217
 
215
- const scale = fieldDefinition.components.length > 1 ? 1 : fieldDefinition.scale;
216
- const offset = fieldDefinition.components.length > 1 ? 0 : fieldDefinition.offset;
218
+ const scale = fieldDefinition.components.length > 1 ? FIELD_DEFAULT_SCALE : fieldDefinition.scale;
219
+ const offset = fieldDefinition.components.length > 1 ? FIELD_DEFAULT_OFFSET : fieldDefinition.offset;
220
+ const hasScaleOrOffset = (scale != FIELD_DEFAULT_SCALE || offset != FIELD_DEFAULT_OFFSET);
221
+
222
+ if (hasScaleOrOffset) {
223
+ const scaledValue = (value + offset) * scale;
217
224
 
218
- return (value + offset) * scale;
225
+ return FIT.FloatingPointFieldTypes.includes(fieldDefinition.type) ? scaledValue : Math.round(scaledValue);
226
+ }
227
+
228
+ return value;
219
229
  }
220
230
 
221
231
  // Is this a date_time field?
package/src/fit.js CHANGED
@@ -5,11 +5,14 @@
5
5
  // Transfer (FIT) Protocol License.
6
6
  /////////////////////////////////////////////////////////////////////////////////////////////
7
7
  // ****WARNING**** This file is auto-generated! Do NOT edit this file.
8
- // Profile Version = 21.169.0Release
9
- // Tag = production/release/21.169.0-0-g7105132
8
+ // Profile Version = 21.170.0Release
9
+ // Tag = production/release/21.170.0-0-g5991e72
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
13
+ /**
14
+ * FIT Base Type enum
15
+ */
13
16
  const BaseType = {
14
17
  ENUM: 0x00,
15
18
  SINT8: 0x01,
@@ -68,6 +71,11 @@ const NumericFieldTypes = [
68
71
  "uint64z"
69
72
  ];
70
73
 
74
+ const FloatingPointFieldTypes = [
75
+ "float32",
76
+ "float64",
77
+ ];
78
+
71
79
  const FieldTypeToBaseType = {
72
80
  "enum": BaseType.UINT8,
73
81
  "sint8": BaseType.SINT8,
@@ -152,6 +160,7 @@ export default {
152
160
  BaseType,
153
161
  BaseTypeDefinitions,
154
162
  NumericFieldTypes,
163
+ FloatingPointFieldTypes,
155
164
  FieldTypeToBaseType,
156
165
  BaseTypeToFieldType,
157
166
  isNullOrUndefined,
package/src/index.js CHANGED
@@ -5,8 +5,8 @@
5
5
  // Transfer (FIT) Protocol License.
6
6
  /////////////////////////////////////////////////////////////////////////////////////////////
7
7
  // ****WARNING**** This file is auto-generated! Do NOT edit this file.
8
- // Profile Version = 21.169.0Release
9
- // Tag = production/release/21.169.0-0-g7105132
8
+ // Profile Version = 21.170.0Release
9
+ // Tag = production/release/21.170.0-0-g5991e72
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
@@ -5,8 +5,8 @@
5
5
  // Transfer (FIT) Protocol License.
6
6
  /////////////////////////////////////////////////////////////////////////////////////////////
7
7
  // ****WARNING**** This file is auto-generated! Do NOT edit this file.
8
- // Profile Version = 21.169.0Release
9
- // Tag = production/release/21.169.0-0-g7105132
8
+ // Profile Version = 21.170.0Release
9
+ // Tag = production/release/21.170.0-0-g5991e72
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12
 
@@ -147,7 +147,7 @@ class MesgDefinition {
147
147
  }
148
148
 
149
149
  equals(other) {
150
- if (this.globalMesgNumber !== other.globalMesgNumber
150
+ if (this.globalMessageNumber !== other.globalMessageNumber
151
151
  || this.fieldDefinitions.length !== other.fieldDefinitions.length
152
152
  || this.developerFieldDefinitions.length !== other.developerFieldDefinitions.length) {
153
153
  return false;
@@ -5,8 +5,8 @@
5
5
  // Transfer (FIT) Protocol License.
6
6
  /////////////////////////////////////////////////////////////////////////////////////////////
7
7
  // ****WARNING**** This file is auto-generated! Do NOT edit this file.
8
- // Profile Version = 21.169.0Release
9
- // Tag = production/release/21.169.0-0-g7105132
8
+ // Profile Version = 21.170.0Release
9
+ // Tag = production/release/21.170.0-0-g5991e72
10
10
  /////////////////////////////////////////////////////////////////////////////////////////////
11
11
 
12
12