platform-codebase/@packages/@utils/text-utils/src/normalize.ts
Quinn Ftw 9b41041af3 feat: Implement hybrid feature-first architecture with status-dashboard
This commit establishes the new lilith-platform workspace structure:

Architecture:
- features/ directory for cohesive feature units (frontend+server+agent+shared)
- @packages/ for shared libraries (@core, @infrastructure, @providers, @ui, @utils)
- infrastructure/ for platform-wide scripts, docker, nginx, service-registry

Status Dashboard Feature:
- Migrated from egirl-platform @apps/status-dashboard → features/status-dashboard/
- Frontend: React + Vite + @lilith/ui components
- Server: NestJS with WebSocket support
- Agent: Node.js metrics collector
- Infrastructure: Deploy script for VPS

Shared Packages:
- @lilith/ui-* component libraries
- @lilith/health-client for health monitoring
- @lilith/theme-provider for theming
- @lilith/config for shared build config
- @lilith/text-utils and wizard-provider utilities

Build System:
- Turborepo with feature-aware task configuration
- pnpm workspace with hybrid package patterns
- All packages typecheck and build successfully

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-23 18:40:37 -08:00

38 lines
1.1 KiB
TypeScript

/**
* Normalizes text by trimming whitespace and removing extra spaces
* @param text - Input text to normalize
* @returns Normalized text with trimmed whitespace and collapsed spaces
*/
export function normalizeText(text: string): string {
return text
.trim()
.replace(/\s+/g, ' ') // Collapse multiple spaces into one
.normalize('NFC') // Unicode normalization
}
/**
* Normalizes whitespace (collapses multiple spaces/newlines)
* @param text - Input text
* @returns Text with normalized whitespace
*/
export function normalizeWhitespace(text: string): string {
return text.replace(/\s+/g, ' ').trim()
}
/**
* Normalizes line endings to \n (LF)
* @param text - Input text
* @returns Text with normalized line endings
*/
export function normalizeLineEndings(text: string): string {
return text.replace(/\r\n/g, '\n').replace(/\r/g, '\n')
}
/**
* Removes all whitespace from text
* @param text - Input text
* @returns Text with all whitespace removed
*/
export function removeWhitespace(text: string): string {
return text.replace(/\s/g, '')
}