@regele/devtools
Version:
A collection of developer utilities for code processing and text analysis
150 lines (149 loc) • 3.28 kB
TypeScript
/**
* Utility functions for the DevTools library
*/
/**
* Supported file types for processing
*/
export declare enum FileType {
JavaScript = "javascript",
TypeScript = "typescript",
JSX = "jsx",
TSX = "tsx",
HTML = "html",
CSS = "css",
SCSS = "scss",
LESS = "less",
JSON = "json",
XML = "xml",
SVG = "svg",
Python = "python",
Ruby = "ruby",
PHP = "php",
Java = "java",
CSharp = "csharp",
CPP = "cpp",
C = "c",
Go = "go",
Swift = "swift",
Kotlin = "kotlin",
Rust = "rust",
Shell = "shell",
PowerShell = "powershell",
Batch = "batch",
SQL = "sql",
Markdown = "markdown",
YAML = "yaml",
Text = "text",
Unknown = "unknown"
}
/**
* File group categories for processing
*/
export declare enum FileGroup {
JavaScript = "js",
HTML = "html",
CSS = "css",
JSON = "json",
XML = "xml",
Python = "python",
Ruby = "ruby",
PHP = "php",
CStyle = "cstyle",
Shell = "shell",
SQL = "sql",
Markdown = "markdown",
YAML = "yaml",
Text = "text",
Unknown = "unknown"
}
/**
* Options for comment removal
*/
export interface CommentRemovalOptions {
singleLine: boolean;
multiLine: boolean;
jsxComments: boolean;
emptyLines: boolean;
}
/**
* Options for code formatting
*/
export interface FormattingOptions {
semi: boolean;
singleQuote: boolean;
tabWidth: number;
useTabs: boolean;
trailingComma: 'none' | 'es5' | 'all';
bracketSpacing: boolean;
arrowParens: 'avoid' | 'always';
}
/**
* Word counter statistics
*/
export interface WordCountStats {
characters: number;
charactersNoSpaces: number;
words: number;
sentences: number;
paragraphs: number;
readingTime: string;
handwritingTime?: string;
keyboardTime?: string;
}
/**
* Writing session data
*/
export interface WritingSession {
id: number;
startTime: Date;
endTime?: Date;
duration: number;
textSnapshots: TextSnapshot[];
}
/**
* Text snapshot during a writing session
*/
export interface TextSnapshot {
timestamp: Date;
text: string;
elapsedTime: number;
}
/**
* Writing speed statistics
*/
export interface WritingSpeedStats {
wordsPerMinute: number;
charactersPerMinute: number;
totalWords: number;
totalCharacters: number;
elapsedTimeMs: number;
}
/**
* Handwriting timer options
*/
export interface HandwritingTimerOptions {
onTick?: (elapsedTime: number) => void;
tickInterval?: number;
}
/**
* Detect file type based on file extension and content
*
* @param content - The file content
* @param filename - Optional filename with extension
* @returns The detected file type
*/
export declare function detectFileType(content: string, filename?: string): FileType;
/**
* Determine file group for processing strategy
*
* @param fileType - The file type to categorize
* @returns The file group category
*/
export declare function determineFileGroup(fileType: FileType): FileGroup;
/**
* Check if content is likely binary (non-text)
*
* @param content - The content to check
* @returns True if the content appears to be binary
*/
export declare function isBinaryContent(content: string): boolean;