MCPcopy Index your code
hub / github.com/code-pushup/cli / camelCaseToKebabCase

Function camelCaseToKebabCase

packages/utils/src/lib/case-conversions.ts:22–29  ·  view source on GitHub ↗
(
  input: T,
)

Source from the content-addressed store, hash-verified

20 * @returns The kebab-case string.
21 */
22export function camelCaseToKebabCase<T extends string>(
23 input: T,
24): CamelCaseToKebabCase<T> {
25 return input
26 .replace(/([a-z])([A-Z])/g, '$1-$2') // Insert dash before uppercase letters
27 .replace(/([A-Z])([A-Z][a-z])/g, '$1-$2') // Handle consecutive uppercase letters
28 .toLowerCase() as CamelCaseToKebabCase<T>;
29}
30
31/**
32 * Converts a string to Title Case.

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected