All files / src/utilities locale-util.ts

69.23% Statements 9/13
70% Branches 7/10
100% Functions 1/1
66.66% Lines 8/12

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  2x 27x     27x 27x 10x 17x     17x     17x    
type LocaleStringDataProps = number | string | Date | undefined;
export const convertToLocaleString = (data: LocaleStringDataProps, culture?: string): LocaleStringDataProps => {
  Iif (!data) {
    return data;
  }
  culture = culture || undefined;
  if (typeof data === 'number') {
    return data.toLocaleString(culture);
  } else Iif (typeof data === 'string' && !window.isNaN(Number(data))) {
    const num = Number(data);
    return num.toLocaleString(culture);
  } else Iif (data instanceof Date) {
    return data.toLocaleDateString(culture);
  }
  return data;
};