fit-file-parser 2.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/fit.js CHANGED
@@ -3000,6 +3000,13 @@ exports.FIT = {
3000
3000
  offset: 0,
3001
3001
  units: 'V',
3002
3002
  },
3003
+ 32: {
3004
+ field: 'battery_level',
3005
+ type: 'uint8',
3006
+ scale: null,
3007
+ offset: 0,
3008
+ units: 'percent',
3009
+ },
3003
3010
  11: {
3004
3011
  field: 'battery_status',
3005
3012
  type: 'battery_status',
@@ -6,18 +6,16 @@ function mapDataIntoLap(inputLaps, lapKey, data) {
6
6
  const laps = [...inputLaps];
7
7
  let index = 0;
8
8
  for (let i = 0; i < laps.length; i++) {
9
- const lap = laps[i];
10
9
  const nextLap = laps[i + 1];
11
10
  const tempData = [];
12
- const lapStartTime = new Date(lap.start_time).getTime();
13
11
  const nextLapStartTime = nextLap
14
12
  ? new Date(nextLap.start_time).getTime()
15
13
  : null;
16
14
  for (let j = index; j < data.length; j++) {
17
15
  const row = data[j];
18
16
  if (nextLap && nextLapStartTime) {
19
- const timestamp = new Date(row.timestamp).getTime();
20
- if (lapStartTime <= timestamp && nextLapStartTime > timestamp) {
17
+ const timestamp = new Date(row.timestamp || row.start_time).getTime();
18
+ if (nextLapStartTime > timestamp) {
21
19
  tempData.push(row);
22
20
  }
23
21
  else if (nextLapStartTime <= timestamp) {
@@ -39,10 +37,8 @@ function mapDataIntoSession(inputSessions, laps) {
39
37
  const sessions = [...inputSessions];
40
38
  let lapIndex = 0;
41
39
  for (let i = 0; i < sessions.length; i++) {
42
- const session = sessions[i];
43
40
  const nextSession = sessions[i + 1];
44
41
  const tempLaps = [];
45
- const sessionStartTime = new Date(session.start_time).getTime();
46
42
  const nextSessionStartTime = nextSession
47
43
  ? new Date(nextSession.start_time).getTime()
48
44
  : null;
@@ -50,8 +46,7 @@ function mapDataIntoSession(inputSessions, laps) {
50
46
  const lap = laps[j];
51
47
  if (nextSession && nextSessionStartTime) {
52
48
  const lapStartTime = new Date(lap.start_time).getTime();
53
- if (sessionStartTime <= lapStartTime
54
- && nextSessionStartTime > lapStartTime) {
49
+ if (nextSessionStartTime > lapStartTime) {
55
50
  tempLaps.push(lap);
56
51
  }
57
52
  else if (nextSessionStartTime <= lapStartTime) {
package/dist/fit.js CHANGED
@@ -2997,6 +2997,13 @@ export const FIT = {
2997
2997
  offset: 0,
2998
2998
  units: 'V',
2999
2999
  },
3000
+ 32: {
3001
+ field: 'battery_level',
3002
+ type: 'uint8',
3003
+ scale: null,
3004
+ offset: 0,
3005
+ units: 'percent',
3006
+ },
3000
3007
  11: {
3001
3008
  field: 'battery_status',
3002
3009
  type: 'battery_status',
package/dist/helper.js CHANGED
@@ -2,18 +2,16 @@ export function mapDataIntoLap(inputLaps, lapKey, data) {
2
2
  const laps = [...inputLaps];
3
3
  let index = 0;
4
4
  for (let i = 0; i < laps.length; i++) {
5
- const lap = laps[i];
6
5
  const nextLap = laps[i + 1];
7
6
  const tempData = [];
8
- const lapStartTime = new Date(lap.start_time).getTime();
9
7
  const nextLapStartTime = nextLap
10
8
  ? new Date(nextLap.start_time).getTime()
11
9
  : null;
12
10
  for (let j = index; j < data.length; j++) {
13
11
  const row = data[j];
14
12
  if (nextLap && nextLapStartTime) {
15
- const timestamp = new Date(row.timestamp).getTime();
16
- if (lapStartTime <= timestamp && nextLapStartTime > timestamp) {
13
+ const timestamp = new Date(row.timestamp || row.start_time).getTime();
14
+ if (nextLapStartTime > timestamp) {
17
15
  tempData.push(row);
18
16
  }
19
17
  else if (nextLapStartTime <= timestamp) {
@@ -35,10 +33,8 @@ export function mapDataIntoSession(inputSessions, laps) {
35
33
  const sessions = [...inputSessions];
36
34
  let lapIndex = 0;
37
35
  for (let i = 0; i < sessions.length; i++) {
38
- const session = sessions[i];
39
36
  const nextSession = sessions[i + 1];
40
37
  const tempLaps = [];
41
- const sessionStartTime = new Date(session.start_time).getTime();
42
38
  const nextSessionStartTime = nextSession
43
39
  ? new Date(nextSession.start_time).getTime()
44
40
  : null;
@@ -46,8 +42,7 @@ export function mapDataIntoSession(inputSessions, laps) {
46
42
  const lap = laps[j];
47
43
  if (nextSession && nextSessionStartTime) {
48
44
  const lapStartTime = new Date(lap.start_time).getTime();
49
- if (sessionStartTime <= lapStartTime
50
- && nextSessionStartTime > lapStartTime) {
45
+ if (nextSessionStartTime > lapStartTime) {
51
46
  tempLaps.push(lap);
52
47
  }
53
48
  else if (nextSessionStartTime <= lapStartTime) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fit-file-parser",
3
3
  "type": "module",
4
- "version": "2.1.0",
4
+ "version": "2.1.1",
5
5
  "private": false,
6
6
  "description": "Parse your .FIT files easily, directly from JS (Garmin, Polar, Suunto)",
7
7
  "author": {
package/tsconfig.cjs.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "module": "commonjs",
5
- "outDir": "./dist/cjs",
6
- "verbatimModuleSyntax": false
7
- }
8
- }
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "outDir": "./dist/cjs",
6
+ "verbatimModuleSyntax": false
7
+ }
8
+ }