/** * Transforms a kebab-case string to camelCase. A kebab-case string * is a string with hyphen character as word separator. * * @param {String} str The hyphenized string * @return {String} The camelized string */ export function kebabToCamel(str) { return str.replace(/-([a-z])/g, g => g[1].toUpperCase()); } /** * Transforms a camelCase to kebab-case. * * @param {String} str The camelized string * @return {String} The hyphenized string */ export function camelToKebab(str) { let kebabCased = str.substr(1) .replace(/[A-Z]/g, g => `-${g[0]}`); return `${str.charAt(0)}${kebabCased}`.toLowerCase(); } /** * Transforms the first letter of a string to uppercase. * * @param {String} str The input string * @return {String} The transformed string */ export function firstUpper(str) { return str.charAt(0).toUpperCase() + str.substr(1); }