UNPKG

@sailboat-computer/data-storage

Version:

Shared data storage library for sailboat computer v3

96 lines (95 loc) 2.7 kB
/** * Time-based downsampling strategy implementation */ import { Downsampler, StoredData, TimeBasedStrategy } from '../../types'; /** * Time-based downsampler implementation */ export declare class TimeBasedDownsampler implements Downsampler { readonly type = "time-based"; /** * Downsample data using time-based strategy * * @param data - Data to downsample * @param strategy - Time-based strategy * @returns Downsampled data */ downsample(data: StoredData[], strategy: TimeBasedStrategy): Promise<StoredData[]>; /** * Downsample data by interval * * @param data - Data to downsample * @param interval - Interval string (e.g., '1m', '5m', '1h') * @param aggregations - Aggregation configurations * @returns Downsampled data */ private downsampleByInterval; /** * Parse interval string to milliseconds * * @param interval - Interval string (e.g., '1m', '5m', '1h') * @returns Interval in milliseconds */ private parseInterval; /** * Group data by specified fields * * @param data - Data to group * @param fields - Fields to group by * @returns Grouped data */ private groupByFields; /** * Apply aggregations to data * * @param data - Data to aggregate * @param aggregations - Aggregation configurations * @returns Aggregated data */ private applyAggregations; /** * Calculate average of field values * * @param data - Data to calculate average from * @param field - Field to calculate average of * @returns Average value */ private calculateAverage; /** * Calculate sum of field values * * @param data - Data to calculate sum from * @param field - Field to calculate sum of * @returns Sum value */ private calculateSum; /** * Calculate minimum of field values * * @param data - Data to calculate minimum from * @param field - Field to calculate minimum of * @returns Minimum value */ private calculateMin; /** * Calculate maximum of field values * * @param data - Data to calculate maximum from * @param field - Field to calculate maximum of * @returns Maximum value */ private calculateMax; /** * Calculate average timestamp * * @param data - Data to calculate average timestamp from * @returns Average timestamp as ISO string */ private calculateAverageTimestamp; } /** * Create a new time-based downsampler * * @returns Time-based downsampler */ export declare function createTimeBasedDownsampler(): Downsampler;