@time2win/t2w 1.4.20 → 1.4.21
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/CHANGELOG.md +4 -0
- package/index.js +11 -9
- package/package.json +1 -1
- package/test.js +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,10 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## 1.4.21 - 2025-03-13
|
|
9
|
+
### Modified
|
|
10
|
+
```paceBrutto``` ```paceNetto``` ```speedBrutto``` ```speedNetto``` properties to support laps
|
|
11
|
+
|
|
8
12
|
## 1.4.20 - 2025-03-13
|
|
9
13
|
### Added
|
|
10
14
|
```paceBrutto``` ```paceNetto``` ```speedBrutto``` ```speedNetto``` properties for individual result
|
package/index.js
CHANGED
|
@@ -209,29 +209,30 @@ var Time2WinAPI = /** @class */ (function () {
|
|
|
209
209
|
var body, event, _a, _b, _c;
|
|
210
210
|
var _d;
|
|
211
211
|
var _this = this;
|
|
212
|
-
|
|
213
|
-
|
|
212
|
+
var _e;
|
|
213
|
+
return __generator(this, function (_f) {
|
|
214
|
+
switch (_f.label) {
|
|
214
215
|
case 0: return [4 /*yield*/, response.json()];
|
|
215
216
|
case 1:
|
|
216
|
-
body =
|
|
217
|
+
body = _f.sent();
|
|
217
218
|
if (response.status === 403) {
|
|
218
219
|
reject(body);
|
|
219
220
|
return [2 /*return*/];
|
|
220
221
|
}
|
|
221
222
|
return [4 /*yield*/, this.getEventData(eventId, ['splits'])];
|
|
222
223
|
case 2:
|
|
223
|
-
event =
|
|
224
|
+
event = _f.sent();
|
|
224
225
|
if (!(body.page < body.page_total)) return [3 /*break*/, 4];
|
|
225
226
|
_b = (_a = (_d = body.list).push).apply;
|
|
226
227
|
_c = [_d];
|
|
227
228
|
return [4 /*yield*/, this.getIndividualResults(eventId, raceId, dataExtra, gender, body.page + 1)];
|
|
228
229
|
case 3:
|
|
229
|
-
_b.apply(_a, _c.concat([(
|
|
230
|
+
_b.apply(_a, _c.concat([(_f.sent()).list]));
|
|
230
231
|
body.page = Math.ceil(body.list.length / body.page_size);
|
|
231
232
|
resolve(body);
|
|
232
|
-
|
|
233
|
+
_f.label = 4;
|
|
233
234
|
case 4:
|
|
234
|
-
body.list = body.list.map(function (p) {
|
|
235
|
+
body.list = (_e = body.list) === null || _e === void 0 ? void 0 : _e.map(function (p) {
|
|
235
236
|
return __assign(__assign({}, p), { birthdate: p.birthdate ? new Date(p.birthdate) : null, racenumNumeric: _this.getNumericBib(p.racenum), speedNetto: _this.calculateSpeed(p, event, 'speed', 'netto') + ' km/h', speedBrutto: _this.calculateSpeed(p, event, 'speed', 'brutto') + ' km/h', paceNetto: _this.calculateSpeed(p, event, 'pace', 'netto') + ' min/km', paceBrutto: _this.calculateSpeed(p, event, 'pace', 'brutto') + ' min/km' });
|
|
236
237
|
});
|
|
237
238
|
resolve(body);
|
|
@@ -393,18 +394,19 @@ var Time2WinAPI = /** @class */ (function () {
|
|
|
393
394
|
var time = timeType === 'netto' ? p.finishtime_fromchip_ms : p.finishtime_fromgun_ms;
|
|
394
395
|
if (!race || !time)
|
|
395
396
|
return '-';
|
|
397
|
+
var distance = race.distance * (p.laps_count || 1);
|
|
396
398
|
// calculate speed in km/h
|
|
397
399
|
if (returnType === 'speed') {
|
|
398
400
|
// Convert time from milliseconds to hours
|
|
399
401
|
var timeHours = time / (1000 * 60 * 60);
|
|
400
402
|
// Convert distance from meters to kilometers
|
|
401
|
-
var distanceKm =
|
|
403
|
+
var distanceKm = distance / 1000;
|
|
402
404
|
// Calculate speed in km/h
|
|
403
405
|
return (distanceKm / timeHours).toFixed(2).replace('.00', '').replace('.', ',');
|
|
404
406
|
}
|
|
405
407
|
if (returnType === 'pace') {
|
|
406
408
|
// Calculate pace in seconds per km
|
|
407
|
-
var paceSecondsPerKm = (time / 1000) / (
|
|
409
|
+
var paceSecondsPerKm = (time / 1000) / (distance / 1000);
|
|
408
410
|
var paceMinutes = Math.floor(paceSecondsPerKm / 60);
|
|
409
411
|
var paceSeconds = Math.round(paceSecondsPerKm % 60);
|
|
410
412
|
// Format pace as mm:ss/km
|
package/package.json
CHANGED
package/test.js
CHANGED
|
@@ -5,4 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
var index_1 = __importDefault(require("./index"));
|
|
7
7
|
var api = new index_1.default('09f006ca-23ee-44da-bec5-4372580f4113');
|
|
8
|
-
api.getIndividualResults(38, 161).then(
|
|
8
|
+
api.getIndividualResults(38, 161).then(function (res) {
|
|
9
|
+
console.log(res.list[0]);
|
|
10
|
+
});
|