export const titleize = (str: string) =>
  humanize(str)
    .split(' ')
    .map(word => word.slice(0, 1).toUpperCase() + word.slice(1))
    .join(' ');

export const humanize = (str: string) =>
  camelToSnakeCase(str)
    .toLowerCase()
    .replace(/[_-]+/g, ' ')
    .replace(/\s{2,}/g, ' ')
    .trim();

export const camelToSnakeCase = (str: string) =>
  str.replace(/[A-Z]/g, letter => `_${letter.toLowerCase()}`);

export const formatUri = (uri: string): string => {
  const arr = uri.split(' ');
  const method = arr.shift();
  return `${method?.toUpperCase()} ${arr.join(' ')}`;
};
