MCPcopy Index your code
hub / github.com/Opencode-DCP/opencode-dynamic-context-pruning / formatTokenCount

Function formatTokenCount

lib/ui/utils.ts:145–151  ·  view source on GitHub ↗
(tokens: number, compact?: boolean)

Source from the content-addressed store, hash-verified

143}
144
145export function formatTokenCount(tokens: number, compact?: boolean): string {
146 const suffix = compact ? "" : " tokens"
147 if (tokens >= 1000) {
148 return `${(tokens / 1000).toFixed(1)}K`.replace(".0K", "K") + suffix
149 }
150 return tokens.toString() + suffix
151}
152
153export function truncate(str: string, maxLen: number = 60): string {
154 if (str.length <= maxLen) return str

Callers 12

ContextDialogFunction · 0.90
StatsDialogFunction · 0.90
formatStatsMessageFunction · 0.90
formatContextMessageFunction · 0.90
formatRecompressMessageFunction · 0.90
formatDecompressMessageFunction · 0.90
buildDetailedMessageFunction · 0.90
formatCompressionMetricsFunction · 0.90
sendCompressNotificationFunction · 0.90
formatStatsHeaderFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected