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

32 lines (31 loc) 1.55 kB
export interface PowerCurveSampleLike { duration: unknown; power: unknown; wattsPerKg?: unknown; } export interface SamplePowerCurveOptions { key?: 'power' | 'wattsPerKg'; maximumBracketDurationRatio?: number; } export interface PowerCurveWindowComparison { durationSeconds: number; recentValue: number | null; referenceValue: number | null; retentionPercent: number | null; deltaPercent: number | null; } export declare const DEFAULT_POWER_CURVE_MAXIMUM_BRACKET_DURATION_RATIO = 1.25; export declare const MAXIMUM_ALLOWED_POWER_CURVE_BRACKET_DURATION_RATIO = 2; /** * Samples a mean-max curve in reciprocal-duration (1/t) space. * * Exact durations win, duplicate durations retain their strongest positive value, and interpolation * requires two neighboring points whose duration ratio is at most 1.25 by default (2 is the hard max). * Durations outside the curve are never extrapolated. */ export declare function samplePowerCurveAtDuration(points: readonly PowerCurveSampleLike[], durationSeconds: number, options?: SamplePowerCurveOptions): number | null; /** * Compares aligned curve samples. Retention is recent/reference × 100; delta is retention minus 100. * Each source curve is normalized and sorted once for the complete duration set. */ export declare function comparePowerCurveWindows(recentPoints: readonly PowerCurveSampleLike[], referencePoints: readonly PowerCurveSampleLike[], durationSeconds: readonly number[], options?: SamplePowerCurveOptions): PowerCurveWindowComparison[];