managarten/apps/context/apps/mobile/utils/textUtils.ts
Till-JS bb0e0cf5cb 🚚 feat(context): integrate context app into monorepo
Restructure the context app (formerly basetext) to follow the monorepo
pattern with proper workspace configuration.

Changes:
- Move app files to apps/context/apps/mobile/
- Rename package to @context/mobile
- Update bundle ID to com.manacore.context
- Create pnpm-workspace.yaml for project workspace
- Add dev scripts to root package.json
- Update CLAUDE.md with project documentation

The app structure is prepared for future web/backend additions.

Note: Existing TypeScript errors in the original codebase are preserved.
These should be fixed in a follow-up PR.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-05 15:09:04 +01:00

27 lines
722 B
TypeScript

/**
* Hilfsfunktionen für Textverarbeitung
*/
/**
* Zählt die Anzahl der Wörter in einem Text
* @param text Der zu zählende Text
* @returns Die Anzahl der Wörter im Text
*/
export const countWords = (text: string): number => {
if (!text) return 0;
return text
.trim()
.split(/\s+/)
.filter((word) => word.length > 0).length;
};
/**
* Berechnet die geschätzte Lesezeit in Minuten
* @param text Der zu lesende Text
* @param wordsPerMinute Wörter pro Minute (Standard: 200)
* @returns Die geschätzte Lesezeit in Minuten
*/
export const calculateReadingTime = (text: string, wordsPerMinute: number = 200): number => {
const words = countWords(text);
return Math.ceil(words / wordsPerMinute);
};