(limit: any, idx: number)
| 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 |
no test coverage detected