@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
28 lines (27 loc) • 1.58 kB
TypeScript
import { DataInterface } from '../data/data.interface';
import { DataJSONInterface } from '../data/data.json.interface';
import { StatsClassInterface } from './stats.class.interface';
type StatsSource = Pick<StatsClassInterface, 'getStat'>;
type NumericRecordReducer = 'sum' | 'min' | 'max' | 'average' | 'weightedAverage';
export interface NumericRecordAggregation {
readonly outputKey: string;
readonly keys: readonly string[];
readonly reducer: NumericRecordReducer;
readonly weightKeys?: readonly string[];
readonly requireCompleteCoverage?: boolean;
}
export declare class StatsUtilities {
static serializeStats(stats: Map<string, DataInterface>): DataJSONInterface;
static getFiniteStatValue(source: StatsSource, statType: string): number | null;
static getFiniteNumericValue(value: unknown): number | null;
static getFiniteNumericRecordValue(source: unknown, keys: readonly string[]): number | null;
static aggregateNumericRecords(records: readonly unknown[], aggregations: readonly NumericRecordAggregation[]): Record<string, number>;
static sum(sources: StatsSource[], statType: string): number | null;
static min(sources: StatsSource[], statType: string): number | null;
static max(sources: StatsSource[], statType: string): number | null;
static average(sources: StatsSource[], statType: string): number | null;
static weightedAverage(sources: StatsSource[], valueStatType: string, weightStatType: string): number | null;
private static getFiniteStatValues;
private static aggregateValues;
}
export {};