@rasifix/orienteering-utils 2.0.20 → 2.0.22

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.
@@ -309,21 +309,19 @@ function defineLegs(runners) {
309
309
  }, {});
310
310
  runners.forEach(function (runner) {
311
311
  runner.splits
312
- //.filter((s) => validTime(s.time))
313
312
  .forEach(function (split, idx) {
314
- var from = idx === 0 ? "St" : runner.splits[idx - 1].code;
315
- var to = split.code;
316
- var code = from + "-" + to;
317
- var current = legs[code];
318
- if (validTime(split.time)) {
313
+ const from = idx === 0 ? "St" : runner.splits[idx - 1].code;
314
+ const to = split.code;
315
+ const code = from + "-" + to;
316
+ const current = legs[code];
317
+ const time = idx === 0 ? split.time : split.time - runner.splits[idx - 1].time;
318
+ if (validTime(time)) {
319
319
  current.runners.push({
320
320
  id: runner.id,
321
321
  fullName: runner.fullName,
322
322
  splitRank: 0,
323
323
  time: split.time,
324
- split: idx === 0
325
- ? split.time
326
- : split.time - runner.splits[idx - 1].time,
324
+ split: time,
327
325
  });
328
326
  }
329
327
  });
@@ -348,7 +346,7 @@ function defineLegProperties(legs) {
348
346
  return r1.split - r2.split;
349
347
  });
350
348
  // calculate the ideal time: take up to 5 fastest on that leg
351
- var selected = leg.runners
349
+ var selected = leg.runners.filter((runner) => !isNaN(runner.split) && runner.split !== undefined)
352
350
  .slice(0, Math.min(leg.runners.length, 5))
353
351
  .map(function (runner) { return runner.split; });
354
352
  // only if there are valid splits for this leg
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rasifix/orienteering-utils",
3
- "version": "2.0.20",
3
+ "version": "2.0.22",
4
4
  "description": "utility functions for orienteering result analyzis",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",