mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-10-01 01:36:00 -04:00
e711290d8b
Had to do some manual fixing of the app.js file due to misplaced comments
20 lines
566 B
JavaScript
20 lines
566 B
JavaScript
/**
|
|
* 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());
|
|
}
|