A collection of developer utilities for code processing and text analysis
npm install @regele/devtools





๐งน Clean โข
๐
Beautify โข
๐ Analyze โข
โฑ๏ธ Time โข
๐ Detect
---
Intelligently strip comments from 30+ file types while preserving code structure and functionality
Format and beautify code with customizable options for consistent style
Comprehensive text analysis with detailed statistics and metrics
Track writing sessions with sophisticated time estimation algorithms
Detect bugs, security issues, and performance bottlenecks in your code
Powerful command-line interface with consistent options across all tools
Works with 30+ languages and file types including:
- JavaScript/TypeScript: .js, .jsx, .ts, .tsx, .mjs, .cjs, .vue, .svelte, .astro
- HTML/XML: .html, .htm, .xml, .svg, .jsp, .asp, .ejs, .hbs
- CSS: .css, .scss, .sass, .less, .stylus, .postcss
- C-style: .c, .h, .cpp, .hpp, .java, .cs, .go, .swift
- Others: .php, .py, .rb, .sql, .md, .txt, .json, .yaml
``bash`
npm install @regele/devtoolsor
yarn add @regele/devtoolsor
pnpm add @regele/devtools
`bash`
npm install -g @regele/devtoolsor
yarn global add @regele/devtoolsor
pnpm add -g @regele/devtools
๐ Requirements
- Node.js: v14.x or higher
- NPM: v6.x or higher
- Operating Systems: Windows, macOS, Linux
- Optional Dependencies:
- Prettier (for enhanced code formatting)
- ESLint (for enhanced code analysis)
`typescript
import { CommentRemover, FileType } from '@regele/devtools';
// Create a new comment remover with default options
const commentRemover = new CommentRemover();
// Remove comments from JavaScript code
const jsCode =
// This is a comment
function hello() {
/* This is a
multiline comment */
console.log('Hello world'); // End of line comment
};
const cleanCode = commentRemover.removeComments(jsCode, FileType.JavaScript);
console.log(cleanCode);
`
`javascript`
function hello() {
console.log('Hello world');
}
`typescript
// Customize removal options
const customRemover = new CommentRemover({
singleLine: true, // Remove single-line comments (// in JS)
multiLine: true, // Remove multi-line comments (/ / in JS)
jsxComments: true, // Remove JSX comments ({/ /} in JSX/TSX)
emptyLines: false // Preserve empty lines after comment removal
});
// Or update options on an existing instance
commentRemover.updateOptions({
singleLine: true,
multiLine: false, // Keep multi-line comments
emptyLines: true
});
// Get current configuration
const options = commentRemover.getOptions();
console.log(options);
`
`typescript
// Process multiple files with glob patterns
const results = await commentRemover.cleanFiles('src/*/.{js,ts}', {
write: true, // Write changes back to files
ignore: ['node_modules/', 'dist/'], // Ignore patterns
silent: false // Show processing output
});
console.log(Processed ${results.length} files);`
`typescript
import { Beautifier, FileType } from '@regele/devtools';
// Create a new beautifier with custom options
const beautifier = new Beautifier({
semi: true,
singleQuote: true,
tabWidth: 2
});
// Format JavaScript code
const jsCode = function hello(){console.log("Hello world")};
// Format code (returns a promise)
const formattedCode = await beautifier.format(jsCode, FileType.JavaScript);
console.log(formattedCode);
`
`javascript`
function hello() {
console.log('Hello world');
}
`typescript
// Create with specific options
const beautifier = new Beautifier({
semi: false, // No semicolons
singleQuote: true, // Use single quotes
tabWidth: 4, // 4-space indentation
useTabs: false, // Use spaces instead of tabs
printWidth: 100, // Line width limit
trailingComma: 'es5', // Trailing commas where valid in ES5
bracketSpacing: true, // Spaces in object literals
arrowParens: 'always' // Parentheses around arrow function parameters
});
// Update options on an existing instance
beautifier.updateOptions({
semi: true,
printWidth: 80
});
`
`typescript
import prettier from 'prettier';
// Use with Prettier for enhanced formatting capabilities
const prettierBeautifier = new Beautifier({
// Prettier options
semi: true,
singleQuote: true
}, prettier);
// Format files with specific parser
const tsCode = interface User{name:string;age:number};`
const formattedTS = await prettierBeautifier.format(tsCode, FileType.TypeScript);
console.log(formattedTS);
`typescript`
interface User {
name: string;
age: number;
}
`typescript
// Format multiple files with glob patterns
const results = await beautifier.formatFiles('src/*/.{js,ts,jsx,tsx}', {
write: true, // Write changes back to files
ignore: ['node_modules/', 'dist/'], // Ignore patterns
silent: false // Show processing output
});
console.log(Beautified ${results.length} files);`
`typescript
import { WordCounter } from '@regele/devtools';
// Create a new word counter with text
const text = "This is a sample text. It has two sentences. And it has multiple paragraphs.\n\nThis is the second paragraph.";
const wordCounter = new WordCounter(text);
// Get all statistics at once
const stats = wordCounter.getStats();
console.log(stats);
`
`javascript`
{
characters: 104,
charactersNoSpaces: 85,
words: 20,
sentences: 3,
paragraphs: 2,
readingTime: "1 min",
handwritingTime: "~3 mins",
keyboardTime: "~2 mins"
}
`typescript
// Get individual statistics
console.log(wordCounter.getWordCount()); // 20
console.log(wordCounter.getSentenceCount()); // 3
console.log(wordCounter.getReadingTime()); // "1 min"
console.log(wordCounter.getHandwritingTime()); // "~3 mins"
// Set new text to analyze
wordCounter.setText("New text to analyze");
// Customize reading/writing speeds (words per minute)
wordCounter.setReadingSpeed(250); // Fast reader
wordCounter.setHandwritingSpeed(20); // Slow writer
wordCounter.setKeyboardSpeed(80); // Fast typist
// Advanced analysis
const frequency = wordCounter.getWordFrequency();
console.log(frequency); // { "new": 1, "text": 1, "to": 1, "analyze": 1 }
// Get most frequent words
const topWords = wordCounter.getMostFrequentWords(5);
console.log(topWords); // [["new", 1], ["text", 1], ["to", 1], ["analyze", 1]]
// Get readability score (Flesch Reading Ease)
const readability = wordCounter.getReadabilityScore();
console.log(readability); // Higher score means easier to read
`
`typescript
// Start a writing session
wordCounter.startWritingSession();
// Update text during the session (this also takes a snapshot)
wordCounter.updateText("Writing in progress...");
// After some time, update with more text
wordCounter.updateText("Writing in progress... Adding more content.");
// Get current writing speed
const writingSpeed = wordCounter.getWritingSpeed();
console.log(writingSpeed);
`
`javascript`
{
wordsPerMinute: 15,
charactersPerMinute: 85,
totalWords: 8,
totalCharacters: 45,
elapsedTimeMs: 32000
}
`typescript
// Timer control methods
wordCounter.pauseWritingSession(); // Pause the timer
wordCounter.startWritingSession(); // Resume the timer
wordCounter.stopWritingSession(); // Stop the current session
wordCounter.resetWritingSession(); // Reset the timer and session
// Get elapsed time
const elapsedTime = wordCounter.getElapsedTime();
const formattedTime = wordCounter.getFormattedElapsedTime(); // "00:05:32"
// Check timer status
const isRunning = wordCounter.isTimerRunning();
// Register tick callback (called every 100ms by default)
wordCounter.onTimerTick((elapsedTime) => {
console.log(Timer running: ${elapsedTime}ms);
});
// Get the complete writing session history
const sessions = wordCounter.getWritingSessionHistory();
console.log(sessions);
`
`javascript`
[
{
id: 1628506892451,
startTime: "2023-08-09T12:34:52.451Z",
duration: 65000,
textSnapshots: [
{
timestamp: "2023-08-09T12:35:12.451Z",
text: "Writing in progress...",
elapsedTime: 20000
},
{
timestamp: "2023-08-09T12:35:42.451Z",
text: "Writing in progress... Adding more content.",
elapsedTime: 50000
}
]
}
]
`typescript
// Analyze multiple text files
const results = await wordCounter.analyzeFiles('content/*/.{md,txt}', {
ignore: ['node_modules/', 'dist/']
});
// Process results
for (const result of results) {
if (result.success) {
console.log(File: ${result.path});Words: ${result.stats?.words}
console.log();Reading time: ${result.stats?.readingTime}
console.log();Most frequent words:
console.log(, result.frequentWords);Readability score: ${result.readabilityScore}
console.log();`
}
}
Add these scripts to your package.json for easy access to all tools:
`json`
"scripts": {
"format": "devtools-beautify src/*/.{js,jsx,ts,tsx,json,css,html}",
"clean": "devtools-clean src/*/.{js,jsx,ts,tsx,json,css,html}",
"analyze": "devtools-analyze src/*/.{js,jsx,ts,tsx,md,txt}",
"analyze-code": "devtools-analyze-code src/*/.{js,jsx,ts,tsx}"
}
Then run with npm:
`bash`
npm run format # Format all project files
npm run clean # Remove comments from all project files
npm run analyze # Analyze text content in project
npm run analyze-code # Analyze code for issues
`bash`Remove comments from files
devtools-clean "src/*/.js" --write
`bashRemove only single-line comments
devtools-clean "src/*/.js" --single-line --no-multi-line --write
Multiple File Types`bash
Process multiple file types at once
devtools-clean "src/*/.{js,ts,jsx,tsx,css,html}" --writeIgnore specific files or directories
devtools-clean "src//.js" --ignore "src/vendor/,/.min.js" --write
`
`bash`Beautify files
devtools-beautify "src/*/.js" --write
`bashUse a custom Prettier config
devtools-beautify "src/*/.js" --config .prettierrc --write
Multiple File Types`bash
Process multiple file types at once
devtools-beautify "src/*/.{js,ts,jsx,tsx,css,html}" --writeIgnore specific files or directories
devtools-beautify "src//.js" --ignore "src/vendor/,/.min.js" --write
`
`bash`Analyze text files
devtools-analyze "src/*/.{md,txt}"
`bashGenerate a detailed JSON report
devtools-analyze "src/*/.{md,txt}" --output report.json
Analysis Includes- Character count (with and without spaces)
- Word, sentence, and paragraph counts
- Reading time estimates (based on 200 words per minute)
- Handwriting time estimates (based on 25 words per minute)
- Keyboard typing time estimates (based on 60 words per minute)
- Readability score (Flesch Reading Ease)
- Most frequent words
`bash`Analyze code for issues
devtools-analyze-code "src/*/.js"
`bashFilter by severity level
devtools-analyze-code "src/*/.js" --severity warning
Report Generation`bash
Generate HTML report
devtools-analyze-code "src/*/.js" --output report.htmlGenerate JSON report
devtools-analyze-code "src/*/.js" --output report.json --format json
`Analysis Categories- Performance: Nested loops, unbatched DOM updates, unthrottled event listeners
- Security: Unsanitized user input, unsafe eval usage, dangerous innerHTML
- Maintainability: Complex functions, deep nesting, duplicated code, missing JSDoc
- Bugs: Off-by-one errors, unhandled promises, null dereferences, inconsistent returns
- Style: Naming conventions, indentation, semicolon usage, function style
`bash`Show help and version
devtools --help
devtools --version
`bash`Run commands through the unified interface
devtools beautify "src/*/.js"
devtools clean "src/*/.js"
devtools analyze "src/*/.md"
devtools analyze-code "src/*/.js"
`bashVerbose output with detailed information
devtools --verbose analyze-code "src/*/.js"
Note: All tools support the same file types, with appropriate processing applied based on the language and file structure.
Configure how comments are removed from your code:
`typescript
// Default options shown
const options = {
singleLine: true, // Remove single-line comments (// in JS)
multiLine: true, // Remove multi-line comments (/ / in JS)
jsxComments: true, // Remove JSX comments ({/ /} in JSX/TSX)
emptyLines: true // Remove empty lines after comment removal
};
const commentRemover = new CommentRemover(options);
`
| Option | Type | Default | Description |
|---|---|---|---|
singleLine | boolean | true | Remove single-line comments like // comment |
multiLine | boolean | true | Remove multi-line comments like / comment / |
jsxComments | boolean | true | Remove JSX comments like {/ comment /} |
emptyLines | boolean | true | Remove empty lines that result from comment removal |
Configure how your code is formatted:
`typescript
// Default options shown
const options = {
semi: true, // Add semicolons
singleQuote: true, // Use single quotes
tabWidth: 2, // Tab width
useTabs: false, // Use spaces instead of tabs
printWidth: 80, // Line width
trailingComma: 'es5',// Trailing commas where valid in ES5
bracketSpacing: true,// Spaces in object literals
arrowParens: 'always'// Parentheses around arrow function parameters
};
const beautifier = new Beautifier(options);
`
| Option | Type | Default | Description |
|---|---|---|---|
semi | boolean | true | Add semicolons at the end of statements |
singleQuote | boolean | true | Use single quotes instead of double quotes |
tabWidth | number | 2 | Number of spaces per indentation level |
useTabs | boolean | false | Use tabs for indentation instead of spaces |
printWidth | number | 80 | Maximum line length before wrapping |
trailingComma | string | 'es5' | Print trailing commas wherever possible when multi-line |
bracketSpacing | boolean | true | Print spaces between brackets in object literals |
arrowParens | string | 'always' | Include parentheses around a sole arrow function parameter |
Configure text analysis and timing calculations:
`typescriptTime: ${elapsed}ms
// Default options shown
const wordCounter = new WordCounter(
"Text to analyze", // Initial text
200, // Reading speed (words per minute)
25, // Handwriting speed (words per minute)
60, // Keyboard typing speed (words per minute)
{ // Timer options
tickInterval: 100, // Timer tick interval in ms
onTick: (elapsed) => console.log()`
}
);
| Parameter | Type | Default | Description |
|---|---|---|---|
text | string | '' | Initial text to analyze |
wordsPerMinute | number | 200 | Reading speed in words per minute |
handwritingWpm | number | 25 | Handwriting speed in words per minute |
keyboardWpm | number | 60 | Keyboard typing speed in words per minute |
timerOptions | object | {} | Options for the handwriting timer |
constructor(options?: Partial<CommentRemovalOptions>)Creates a new CommentRemover instance with optional configuration.
removeComments(code: string, fileType?: FileType | string): stringRemoves comments from the provided code string based on the file type.
updateOptions(options: Partial<CommentRemovalOptions>): voidUpdates the comment removal options for this instance.
getOptions(): CommentRemovalOptionsReturns the current comment removal options.
cleanFiles(patterns: string | string[], options?: FileOptions): Promise<FileResult[]>Processes multiple files matching the glob patterns and removes comments.
constructor(options?: Partial<FormattingOptions>, prettier?: any)Creates a new Beautifier instance with optional formatting options and Prettier instance.
format(code: string, fileType?: FileType | string): Promise<string>Formats the provided code string based on the file type.
updateOptions(options: Partial<FormattingOptions>): voidUpdates the formatting options for this instance.
getOptions(): FormattingOptionsReturns the current formatting options.
setPrettier(prettier: any): voidSets a custom Prettier instance for enhanced formatting capabilities.
formatFiles(patterns: string | string[], options?: object): Promise<Result[]>Processes multiple files matching the glob patterns and formats them.
Analyzes text for statistics and provides timing estimates.
#### Constructor & Basic Methods
- constructor(text: string = '', wordsPerMinute: number = 200, handwritingWpm: number = 25, keyboardWpm: number = 60, timerOptions?: HandwritingTimerOptions): Creates a new WordCounter instance with optional text and timing parameters.setText(text: string): void
- : Sets the text to analyze.getText(): string
- : Gets the current text being analyzed.
#### Speed Settings
- setReadingSpeed(wordsPerMinute: number): void: Sets the reading speed in words per minute.getReadingSpeed(): number
- : Gets the current reading speed.setHandwritingSpeed(wordsPerMinute: number): void
- : Sets the handwriting speed in words per minute.getHandwritingSpeed(): number
- : Gets the current handwriting speed.setKeyboardSpeed(wordsPerMinute: number): void
- : Sets the keyboard typing speed in words per minute.getKeyboardSpeed(): number
- : Gets the current keyboard typing speed.
#### Text Statistics
- getStats(): WordCountStats: Gets all text statistics in a single object.getCharacterCount(): number
- : Gets the total character count.getCharacterCountNoSpaces(): number
- : Gets the character count excluding spaces.getWordCount(): number
- : Gets the word count.getSentenceCount(): number
- : Gets the sentence count.getParagraphCount(): number
- : Gets the paragraph count.
#### Time Estimates
- getReadingTime(): string: Gets the estimated reading time as a formatted string.getHandwritingTime(): string
- : Gets the estimated handwriting time as a formatted string.getKeyboardTime(): string
- : Gets the estimated keyboard typing time as a formatted string.
#### Advanced Analysis
- getWordFrequency(): Record: Gets the frequency of each word in the text.getMostFrequentWords(limit: number = 10): [string, number][]
- : Gets the most frequently used words in the text.getReadabilityScore(): number
- : Gets the readability score (Flesch Reading Ease).analyzeFiles(patterns: string | string[], options?: object): Promise
- : Analyzes multiple files matching the glob patterns.
#### Writing Session
- startWritingSession(): void: Starts or resumes a writing session timer.pauseWritingSession(): void
- : Pauses the current writing session timer.stopWritingSession(): void
- : Stops the current writing session timer.resetWritingSession(): void
- : Resets the writing session timer and history.updateText(text: string): void
- : Updates the text and takes a snapshot for the timer.getWritingSpeed(): WritingSpeedStats
- : Gets the current writing speed statistics.getWritingSessionHistory(): WritingSession[]
- : Gets the complete writing session history.getElapsedTime(): number
- : Gets the elapsed time in milliseconds.getFormattedElapsedTime(): string
- : Gets the elapsed time as a formatted string (HH:MM:SS).isTimerRunning(): boolean
- : Checks if the writing timer is currently running.onTimerTick(callback: (elapsedTime: number) => void): void
- : Sets a callback function for timer tick events.
Tracks writing sessions with detailed statistics and snapshots.
- constructor(options?: HandwritingTimerOptions): Creates a new HandwritingTimer instance with optional configuration.start(): void
- : Starts or resumes the timer.pause(): void
- : Pauses the timer.stop(): void
- : Stops the timer and finalizes the current session.reset(): void
- : Resets the timer and clears the current session.takeTextSnapshot(text: string): void
- : Takes a snapshot of the current text for writing speed calculation.calculateWritingSpeed(): WritingSpeedStats
- : Calculates the writing speed based on text snapshots.getSessionHistory(): WritingSession[]
- : Gets the complete session history.getElapsedTime(): number
- : Gets the elapsed time in milliseconds.getFormattedTime(): string
- : Gets the elapsed time as a formatted string (HH:MM:SS).isTimerRunning(): boolean
- : Checks if the timer is currently running.onTick(callback: (elapsedTime: number) => void): void
- : Sets a callback function for timer tick events.
Analyzes code for potential issues, bugs, and improvements.
#### Methods
- constructor(options?: CodeAnalysisOptions): Creates a new CodeAnalyzer instance with optional configuration.analyzeFile(filePath: string): Promise
- : Analyzes a single file for issues and returns detailed results.analyzeFiles(patterns: string | string[]): Promise
- : Analyzes multiple files matching the glob patterns.
#### Examples
`typescript
import { CodeAnalyzer, SeverityLevel, CategoryType } from '@regele/devtools';
// Create analyzer with custom options
const analyzer = new CodeAnalyzer({
minSeverity: SeverityLevel.Warning, // Only report warnings and above
categories: [ // Only include these categories
CategoryType.Security,
CategoryType.Performance
],
maxDepth: 3, // Maximum recursion depth
ignore: ['node_modules/', 'dist/'] // Patterns to ignore
});
// Analyze a single file
const result = await analyzer.analyzeFile('src/app.js');
console.log(Found ${result.findings.length} issues in ${result.filePath});
// Process findings
result.findings.forEach(finding => {
console.log([${finding.severity}] ${finding.message} at line ${finding.line});Category: ${finding.category}
console.log();Suggestion: ${finding.suggestion}
console.log();
});
// Analyze multiple files
const results = await analyzer.analyzeFiles('src/*/.js');
const totalIssues = results.reduce((sum, r) => sum + r.findings.length, 0);
console.log(Found ${totalIssues} issues across ${results.length} files);
// Calculate quality score
const qualityScore = results.reduce((score, result) => {
// Higher score means better quality
const fileScore = 100 - (result.findings.length * 5);
return score + Math.max(0, fileScore);
}, 0) / results.length;
console.log(Overall code quality score: ${qualityScore.toFixed(2)}/100);``
#### Analysis Categories
The CodeAnalyzer detects issues in the following categories:
- Performance: Nested loops, unbatched DOM updates, unthrottled event listeners
- Security: Unsanitized user input, unsafe eval usage, dangerous innerHTML
- Maintainability: Complex functions, deep nesting, duplicated code, missing JSDoc
- Bugs: Off-by-one errors, unhandled promises, null dereferences, inconsistent returns
- Style: Naming conventions, indentation, semicolon usage, function style
This project is licensed under the MIT License - see the LICENSE file for details.
Copyright ยฉ 2025 Regele
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
---