UNPKG

@regele/devtools

Version:

A collection of developer utilities for code processing and text analysis

106 lines (105 loc) 2.55 kB
import { HandwritingTimerOptions, WritingSession, WritingSpeedStats } from './utils'; /** * HandwritingTimer class for tracking writing sessions */ export declare class HandwritingTimer { private startTime; private elapsedTime; private isRunning; private intervalId; private sessionHistory; private currentSession; private onTickCallback; private tickInterval; /** * Create a new HandwritingTimer instance * * @param options - Configuration options */ constructor(options?: HandwritingTimerOptions); /** * Start the timer */ start(): void; /** * Pause the timer */ pause(): void; /** * Stop the timer and reset */ stop(): void; /** * Reset the timer without saving the session */ reset(): void; /** * Take a snapshot of the current text * * @param text - The current text */ takeTextSnapshot(text: string): void; /** * Calculate writing speed based on the latest text snapshot * * @returns Writing speed statistics */ calculateWritingSpeed(): WritingSpeedStats; /** * Get words per minute (WPM) from the latest calculation * * @returns The words per minute or 0 if no data available */ get wpm(): number; /** * Get total words written from the latest calculation * * @returns The total words or 0 if no data available */ get words(): number; /** * Get session history * * @returns Array of writing sessions */ getSessionHistory(): WritingSession[]; /** * Get current elapsed time in milliseconds * * @returns Elapsed time in milliseconds */ getElapsedTime(): number; /** * Get formatted time display (HH:MM:SS) * * @returns Formatted time string */ getFormattedTime(): string; /** * Check if timer is currently running * * @returns True if timer is running */ isTimerRunning(): boolean; /** * Set callback for timer tick events * * @param callback - Function to call on each tick */ onTick(callback: (elapsedTime: number) => void): void; /** * Format time in milliseconds to HH:MM:SS * * @param ms - Time in milliseconds * @returns Formatted time string */ private formatTime; /** * Start the timer interval */ private startInterval; /** * Clear the timer interval */ private clearInterval; }