MCPcopy Create free account
hub / github.com/arctic-cli/interface / formatZaiLimitRow

Function formatZaiLimitRow

packages/arctic/src/provider/usage.ts:408–427  ·  view source on GitHub ↗
(limit: any, idx: number)

Source from the content-addressed store, hash-verified

406 }
407
408 function formatZaiLimitRow(limit: any, idx: number): string {
409 const label = formatZaiLimitLabel(limit, idx)
410 const total = typeof limit?.usage === "number" ? limit.usage : undefined
411 const used =
412 typeof limit?.currentValue === "number"
413 ? limit.currentValue
414 : total !== undefined && typeof limit?.remaining === "number"
415 ? Math.max(0, total - limit.remaining)
416 : undefined
417 const percent = resolveZaiUsedPercent(limit)
418
419 if (total !== undefined && used !== undefined) {
420 const percentLabel = percent !== undefined ? ` (${percent.toFixed(0)}%)` : ""
421 return `${label}: ${used.toLocaleString()} / ${total.toLocaleString()}${percentLabel}`
422 }
423 if (percent !== undefined) {
424 return `${label}: ${percent.toFixed(0)}% used`
425 }
426 return `${label}: usage unknown`
427 }
428
429 function formatZaiLimitLabel(limit: any, idx: number): string {
430 const type = typeof limit?.type === "string" ? limit.type : undefined

Callers 1

fetchZaiUsageLimitsFunction · 0.85

Calls 2

formatZaiLimitLabelFunction · 0.85
resolveZaiUsedPercentFunction · 0.85

Tested by

no test coverage detected