All files / helpers stringHelper.ts

100% Statements 24/24
62.5% Branches 5/8
100% Functions 3/3
100% Lines 24/24

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 251x 1x 1x 25x 25x 25x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 4x 40x 5x 5x 40x 40x 4x 4x  
const capitalizeAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
 
export const capitalizeFirstLetter = (orig: string) => {
  if (orig.length == 0) return orig;
  return [orig[0].toUpperCase(), ...orig.slice(1, orig.length)].join('');
};
 
export const lowercaseFirstLetter = (orig: string) => {
  if (orig.length == 0) return orig;
  return [orig[0].toLowerCase(), ...orig.slice(1, orig.length)].join('');
};
 
export const addSpacesForEnum = (orig: string) => {
  if (orig.length == 0) return orig;
  let result = '';
 
  for (const char of orig) {
    if (capitalizeAlphabet.includes(char)) {
      result += ' ';
    }
    result += char;
  }
  return result;
};