All files / shared naming.ts

92.85% Statements 13/14
50% Branches 2/4
83.33% Functions 5/6
88.88% Lines 8/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 1714x   14x     42x   18x   14x   14x   14x   14x  
const WORD_BOUNDARY = /([a-z])(?=[A-Z0-9])|([0-9])(?=[A-Za-z])|([A-Z])(?=[A-Z][a-z])/g
 
export const fmt = (value: number | null | undefined, digits: number) =>
  value == null ? '—' : Intl.NumberFormat('en', { maximumFractionDigits: digits }).format(value)
 
export const words = (name: string) => name.replace(WORD_BOUNDARY, '$1$2$3 ')
 
export const plural = (count: number, noun: string) => (count === 1 ? noun : `${noun}s`)
 
export const counted = (count: number, noun: string) => `${count} ${plural(count, noun)}`
 
const PERCENT = 100
 
export const countLabel = (count: number) => count.toLocaleString('en')
 
export const percentLabel = (share: number) => `${Math.round(share * PERCENT)}%`