murmuraba
Version:
Real-time audio noise reduction with advanced chunked processing for web applications
69 lines • 2.19 kB
TypeScript
/**
* Unified time formatting utilities for consistent duration handling across the application.
* All durations are stored internally as milliseconds for precision.
*/
export type TimeUnit = 'milliseconds' | 'seconds';
export type TimeFormat = 'mm:ss' | 'hh:mm:ss' | 'compact';
export interface TimeFormatOptions {
format?: TimeFormat;
showHours?: boolean;
precision?: 'seconds' | 'milliseconds';
}
/**
* Convert time between different units
*/
export declare const convertTime: {
msToSeconds: (ms: number) => number;
secondsToMs: (seconds: number) => number;
msToMinutes: (ms: number) => number;
minutesToMs: (minutes: number) => number;
};
/**
* Validate and normalize time values
*/
export declare const normalizeTime: (time: number) => number;
/**
* Core time formatting function that accepts milliseconds
* This is the single source of truth for time formatting
*/
export declare const formatDuration: (milliseconds: number, options?: TimeFormatOptions) => string;
/**
* Legacy compatibility - formats seconds to mm:ss
* @deprecated Use formatDuration with convertTime.secondsToMs() instead
*/
export declare const formatTime: (seconds: number) => string;
/**
* Format duration with automatic unit detection and user-friendly labels
*/
export declare const formatDurationWithLabel: (milliseconds: number) => string;
/**
* Create a time formatter with consistent options
*/
export declare const createTimeFormatter: (options?: TimeFormatOptions) => (milliseconds: number) => string;
/**
* Utility for chunk duration statistics
*/
export declare const calculateDurationStats: (durations: number[]) => {
total: number;
average: number;
min: number;
max: number;
totalFormatted: string;
averageFormatted: string;
minFormatted?: undefined;
maxFormatted?: undefined;
} | {
total: number;
average: number;
min: number;
max: number;
totalFormatted: string;
averageFormatted: string;
minFormatted: string;
maxFormatted: string;
};
/**
* Type guard for time values
*/
export declare const isValidTime: (value: unknown) => value is number;
//# sourceMappingURL=time-utils.d.ts.map