(text: string)
| 2 | |
| 3 | /** 1 token ≈ 4 characters for English text */ |
| 4 | export function estimateTokens(text: string): number { |
| 5 | if (!text?.trim()) return 0 |
| 6 | return Math.ceil(text.length / 4) |
| 7 | } |
| 8 | |
| 9 | export function tokensToChars(tokens: number): number { |
| 10 | return tokens * 4 |
no outgoing calls
no test coverage detected