UNPKG

@sports-alliance/sports-lib

Version:

A Library to for importing / exporting and processing GPX, TCX, FIT and JSON files from services such as Strava, Movescount, Garmin, Polar etc

24 lines (23 loc) 997 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPrimaryActivityForStreamRegression = getPrimaryActivityForStreamRegression; exports.getUniqueStreamTypes = getUniqueStreamTypes; exports.getDuplicateStreamTypes = getDuplicateStreamTypes; function getPrimaryActivityForStreamRegression(event) { return event .getActivities() .reduce((previous, current) => previous.getDuration().getValue() > current.getDuration().getValue() ? previous : current); } function getUniqueStreamTypes(activity) { return Array.from(new Set(activity.getAllStreams().map(stream => stream.type))); } function getDuplicateStreamTypes(activity) { const counts = new Map(); activity.getAllStreams().forEach(stream => { counts.set(stream.type, (counts.get(stream.type) || 0) + 1); }); return Array.from(counts.entries()) .filter(([, count]) => count > 1) .map(([type]) => type) .sort((a, b) => a.localeCompare(b)); }