From 6959537d9e96093c37c7b8e69473d78067879233 Mon Sep 17 00:00:00 2001 From: Rene Saarsoo Date: Sun, 20 Sep 2020 15:58:35 +0300 Subject: [PATCH] Improve formatting of main index.ts file --- src/index.ts | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/src/index.ts b/src/index.ts index e5b7442..c1b0700 100644 --- a/src/index.ts +++ b/src/index.ts @@ -13,31 +13,20 @@ console.log(`Parsing: ${filename}`); const file = fs.readFileSync(filename, "utf8"); -const workout = parse(tokenize(file)); +const { intervals } = parse(tokenize(file)); -console.log(workout.intervals); +const duration = totalDuration(intervals); +const avgIntensity = averageIntensity(intervals); +const normIntensity = normalizedIntensity(intervals); -console.log(); -console.log("Total TSS: " + tss(workout.intervals).toFixed()); +console.log(intervals); -console.log(); -console.log( - `Total duration: ${(totalDuration(workout.intervals) / 60).toFixed()} minutes` -); +console.log(` +Total duration: ${(duration / 60).toFixed()} minutes -console.log(); -console.log( - `Average intensity: ${(averageIntensity(workout.intervals) * 100).toFixed()}%` -); -console.log( - `Normalized intensity: ${( - normalizedIntensity(workout.intervals) * 100 - ).toFixed()}%` -); +Average intensity: ${(avgIntensity * 100).toFixed()}% +Normalized intensity: ${(normIntensity * 100).toFixed()}% -console.log( - `TSS: ${tss2( - totalDuration(workout.intervals), - normalizedIntensity(workout.intervals) - )}` -); +TSS #1: ${tss(intervals).toFixed()} +TSS #2: ${tss2(duration, normIntensity).toFixed()} +`);