/**
 * It replaces all uppercase letters in a string with a dash followed by the lowercase version of that letter
 *
 * @param {string} str - string - The string to convert.
 * @returns {string} The dash case format like: 'a-b-c'.
 */
const camelToDashCase = (str) => {
  return str.replace(/([A-Z])/g, (m) => `-${m[0].toLowerCase()}`);
};
/**
 * It capitalizes the first letter after the - in the string.
 *
 * @param {string} str - string - The string to convert like: 'white-space'.
 * @returns {string} The camel case format like: 'whiteSpace'.
 */
const dashCaseToCamel = (str) => str
  .split('-')
  .map((word, index) => (index === 0 ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1))
  .join('');

export { camelToDashCase as c, dashCaseToCamel as d };
