diff --git a/src/index.ts b/src/index.ts index 728ef9d..3306b60 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,3 +10,4 @@ export { Intensity, ConstantIntensity, RangeIntensity, FreeIntensity } from "./I // stats utils export { totalDuration } from "./stats/totalDuration"; +export { intensityToZoneIndex, ZoneIndex } from "./stats/zoneDistribution"; diff --git a/src/stats/zoneDistribution.ts b/src/stats/zoneDistribution.ts index 1305415..2bc67d5 100644 --- a/src/stats/zoneDistribution.ts +++ b/src/stats/zoneDistribution.ts @@ -1,10 +1,11 @@ import { Interval } from "../ast"; import { Duration } from "../Duration"; +import { Intensity } from "../Intensity"; import { intervalsToIntensityNumbers } from "./intervalsToIntensityNumbers"; type NumericZoneDuration = { name: string; duration: number }; type ZoneDuration = { name: string; duration: Duration }; -type ZoneIndex = 0 | 1 | 2 | 3 | 4 | 5; +export type ZoneIndex = 0 | 1 | 2 | 3 | 4 | 5; const emptyZones = (): NumericZoneDuration[] => [ { name: "Z1: Recovery", duration: 0 }, @@ -35,6 +36,9 @@ const zoneIndex = (intensity: number): ZoneIndex => { return 0; }; +// For external use (consumes Intensity interface instead of plain number) +export const intensityToZoneIndex = (intensity: Intensity): ZoneIndex => zoneIndex(intensity.value); + export const zoneDistribution = (intervals: Interval[]): ZoneDuration[] => { const zones = emptyZones();