ccusage-live
Version:
Enhanced Claude Code usage analysis tool with live team monitoring and collaboration features
13 lines (12 loc) • 655 B
JavaScript
/**
* Calculates the total number of tokens across all token types
* Supports both raw usage data format and aggregated data format
* @param tokenCounts - Object containing counts for each token type
* @returns Total number of tokens
*/
function getTotalTokens(tokenCounts) {
const cacheCreation = "cacheCreationInputTokens" in tokenCounts ? tokenCounts.cacheCreationInputTokens : tokenCounts.cacheCreationTokens;
const cacheRead = "cacheReadInputTokens" in tokenCounts ? tokenCounts.cacheReadInputTokens : tokenCounts.cacheReadTokens;
return tokenCounts.inputTokens + tokenCounts.outputTokens + cacheCreation + cacheRead;
}
export { getTotalTokens };