export const stringUtil = {
  // 首写字母大写
  firstToUpper: (str: String) => {
    return str.trim().replace(str[0], str[0].toUpperCase());
  },
  // 首写字母小写
  firstToLower: (str: String) => {
    return str.trim().replace(str[0], str[0].toLowerCase());
  },

  // 下划线转换驼峰
  toHump: (str: string) => {
    return str.replace(/\_(\w)/g, function (all, letter) {
      return letter.toUpperCase();
    });
  },

  // 驼峰转换下划线
  toLine: (str: string) => {
    let newStr = str.replace(/([A-Z])/g, '_$1').toLowerCase();
    return newStr.startsWith('_') ? newStr.replace('_', '') : newStr;
  },
};
