Connected md editor settings to logic for functionality

This commit is contained in:
Dan Brown
2022-11-28 12:12:36 +00:00
parent 9fd5190c70
commit ec3713bc74
10 changed files with 99 additions and 28 deletions

View File

@ -0,0 +1,19 @@
/**
* Convert a kebab-case string to camelCase
* @param {String} kebab
* @returns {string}
*/
export function kebabToCamel(kebab) {
const ucFirst = (word) => word.slice(0,1).toUpperCase() + word.slice(1);
const words = kebab.split('-');
return words[0] + words.slice(1).map(ucFirst).join('');
}
/**
* Convert a camelCase string to a kebab-case string.
* @param {String} camelStr
* @returns {String}
*/
export function camelToKebab(camelStr) {
return camelStr.replace(/[A-Z]/g, (str, offset) => (offset > 0 ? '-' : '') + str.toLowerCase());
}