All files / src/utils/nrwl name-utils.ts

90.9% Statements 10/11
50% Branches 1/2
85.71% Functions 6/7
90.9% Lines 10/11

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 17 18 19 20 21 22 23 24 25 26 27 28 29 3022x 18x               22x 18x     22x 36x 18x       22x 51x             18x    
export function names(name: string): any {
  return {
    name,
    className: toClassName(name),
    propertyName: toPropertyName(name),
    fileName: toFileName(name),
  };
}
 
export function toClassName(str: string): string {
  return toCapitalCase(toPropertyName(str));
}
 
export function toPropertyName(s: string): string {
  return s
    .replace(/(-|_|\.|\s)+(.)?/g, (_, __, chr) => (chr ? chr.toUpperCase() : ''))
    .replace(/^([A-Z])/, (m) => m.toLowerCase());
}
 
export function toFileName(s: string): string {
  return s
    .replace(/([a-z\d])([A-Z])/g, '$1_$2')
    .toLowerCase()
    .replace(/[ _]/g, '-');
}
 
function toCapitalCase(s: string): string {
  return s.charAt(0).toUpperCase() + s.substr(1);
}