mirror of
https://github.com/zoriya/v10.git
synced 2026-08-13 01:19:44 +00:00
24 lines
507 B
TypeScript
24 lines
507 B
TypeScript
/**
|
|
* Converts a string to camel case.
|
|
*
|
|
* @param str - The string to convert.
|
|
* @returns The camel case string.
|
|
*/
|
|
export function toCamelCase(str: string): string {
|
|
return str
|
|
.toLowerCase()
|
|
.replace(/[-_]([a-z])/g, (_$0, $1) => $1.toUpperCase());
|
|
}
|
|
|
|
/**
|
|
* Converts a string to kebab case.
|
|
*
|
|
* @param str - The string to convert.
|
|
* @returns The kebab case string.
|
|
*/
|
|
export function toKebabCase(str: string): string {
|
|
return str
|
|
.replace(/([A-Z])/g, '-$1')
|
|
.toLowerCase();
|
|
}
|