Spaces:
Sleeping
Sleeping
| export function compactNumber(value) { | |
| const number = Number(value) || 0; | |
| return Intl.NumberFormat('en', { notation: number >= 10000 ? 'compact' : 'standard' }).format(number); | |
| } | |
| export function percent(value) { | |
| return `${Math.round(Number(value) || 0)}%`; | |
| } | |
| export function titleCase(value = '') { | |
| return value | |
| .replace(/[_-]/g, ' ') | |
| .replace(/\w\S*/g, (word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()); | |
| } | |
| export function repoShortName(url = '') { | |
| try { | |
| const path = new URL(url).pathname.replace(/^\/|\.git$/g, ''); | |
| return path || url; | |
| } catch { | |
| return url.split('/').slice(-2).join('/'); | |
| } | |
| } | |
| export function riskColor(level = 'LOW') { | |
| const key = String(level).toUpperCase(); | |
| return { | |
| CRITICAL: '#EF4444', | |
| HIGH: '#F97316', | |
| MEDIUM: '#F59E0B', | |
| LOW: '#10B981', | |
| }[key] || '#64748B'; | |
| } | |