fit-file-parser 1.9.4 → 1.9.5

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.
@@ -208,7 +208,10 @@ var FitParser = function () {
208
208
 
209
209
  if (isCascadeNeeded) {
210
210
  fitObj.activity = fitObj.activity || {};
211
- fitObj.activity.sessions = (0, _helper.mapDataIntoSession)(sessions, laps, lengths, records);
211
+ laps = (0, _helper.mapDataIntoLap)(laps, 'records', records);
212
+ laps = (0, _helper.mapDataIntoLap)(laps, 'lengths', lengths);
213
+ sessions = (0, _helper.mapDataIntoSession)(sessions, laps);
214
+ fitObj.activity.sessions = sessions;
212
215
  fitObj.activity.events = events;
213
216
  fitObj.activity.hrv = hrv;
214
217
  fitObj.activity.device_infos = devices;
package/dist/helper.js CHANGED
@@ -1,25 +1,27 @@
1
- 'use strict';
1
+ "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+
7
+ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
8
+
6
9
  var mapDataIntoLap = exports.mapDataIntoLap = function mapDataIntoLap(inputLaps, lapKey, data) {
7
- var laps = JSON.parse(JSON.stringify(inputLaps));
10
+ var laps = [].concat(_toConsumableArray(inputLaps));
8
11
  var index = 0;
9
12
  for (var i = 0; i < laps.length; i++) {
10
13
  var lap = laps[i];
11
14
  var nextLap = laps[i + 1];
12
15
  var tempData = [];
13
- var lapStartTime = new Date(lap.startTime).getTime();
16
+ var lapStartTime = new Date(lap.start_time).getTime();
14
17
  var nextLapStartTime = nextLap ? new Date(nextLap.start_time).getTime() : null;
15
18
  for (var j = index; j < data.length; j++) {
16
19
  var row = data[j];
17
20
  if (nextLap) {
18
21
  var timestamp = new Date(row.timestamp).getTime();
19
- if (lapStartTime <= timestamp && nextLapStartTime >= timestamp) {
22
+ if (lapStartTime <= timestamp && nextLapStartTime > timestamp) {
20
23
  tempData.push(row);
21
- } else if (nextLapStartTime < timestamp) {
22
- laps[i][lapKey] = tempData;
24
+ } else if (nextLapStartTime <= timestamp) {
23
25
  index = j;
24
26
  break;
25
27
  }
@@ -36,11 +38,8 @@ var mapDataIntoLap = exports.mapDataIntoLap = function mapDataIntoLap(inputLaps,
36
38
  return laps;
37
39
  };
38
40
 
39
- var mapDataIntoSession = exports.mapDataIntoSession = function mapDataIntoSession(inputSessions, inputLaps, lengths, records) {
40
- var sessions = JSON.parse(JSON.stringify(inputSessions));
41
- var laps = JSON.parse(JSON.stringify(inputLaps));
42
- laps = mapDataIntoLap(laps, 'lengths', lengths);
43
- laps = mapDataIntoLap(laps, 'records', records);
41
+ var mapDataIntoSession = exports.mapDataIntoSession = function mapDataIntoSession(inputSessions, laps) {
42
+ var sessions = [].concat(_toConsumableArray(inputSessions));
44
43
  var lapIndex = 0;
45
44
  for (var i = 0; i < sessions.length; i++) {
46
45
  var session = sessions[i];
@@ -52,10 +51,9 @@ var mapDataIntoSession = exports.mapDataIntoSession = function mapDataIntoSessio
52
51
  var lap = laps[j];
53
52
  if (nextSession) {
54
53
  var lapStartTime = new Date(lap.start_time).getTime();
55
- if (sessionStartTime <= lapStartTime && nextSessionStartTime >= lapStartTime) {
54
+ if (sessionStartTime <= lapStartTime && nextSessionStartTime > lapStartTime) {
56
55
  tempLaps.push(lap);
57
- } else if (nextSessionStartTime < lapStartTime) {
58
- sessions[i].laps = tempLaps;
56
+ } else if (nextSessionStartTime <= lapStartTime) {
59
57
  lapIndex = j;
60
58
  break;
61
59
  }
package/package.json CHANGED
@@ -71,7 +71,7 @@
71
71
  "test": "node_modules/gulp/bin/gulp.js;",
72
72
  "build": "node_modules/gulp/bin/gulp.js babel"
73
73
  },
74
- "version": "1.9.4",
74
+ "version": "1.9.5",
75
75
  "dependencies": {
76
76
  "buffer": "^5.1.0"
77
77
  }