All files / lib/miscelanea string.ts

27.27% Statements 6/22
0% Branches 0/20
0% Functions 0/6
28.57% Lines 6/21
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  1x 1x         1x         1x         1x         1x    
 
export const capitalize = (string :string) : string => {
    if (string === null || string === undefined) return '';
    return string.toLowerCase().replace(/\b./g, (a) => { return a.toUpperCase(); });
  };
  
  export const cfirst = (string: string) : string => {
    if (string === null || string === undefined) return '';
    return string.charAt(0).toUpperCase() + string.slice(1);
  };
  
  export const lower = (string: string) : string => {
    if (string === null || string === undefined) return '';
    return string.toLowerCase();
  };
  
  export const upper = (string: string) : string => {
    if (string === null || string === undefined) return '';
    return string.toUpperCase();
  };
  
  export const cleanLineBreak = (string: string) : string => {
    if (string === null || string === undefined) return '';
    return string.replace(/(\r\n|\n|\r)/gm, ' ');
  };