@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
27 lines (26 loc) • 1.07 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EventExporterJSON = void 0;
var EventExporterJSON = /** @class */ (function () {
function EventExporterJSON() {
this.fileType = 'application/json';
this.fileExtension = 'json';
}
EventExporterJSON.prototype.getAsString = function (event) {
return new Promise(function (resolve, reject) {
var jsonEvent = event.toJSON();
jsonEvent.activities = event.getActivities().reduce(function (activities, activity) {
var jsonActivity = activity.toJSON();
jsonActivity.streams = activity.getAllStreams().reduce(function (streams, stream) {
streams.push(stream.toJSON());
return streams;
}, []);
activities.push(jsonActivity);
return activities;
}, []);
resolve(JSON.stringify(jsonEvent));
});
};
return EventExporterJSON;
}());
exports.EventExporterJSON = EventExporterJSON;