INNER CODE UNIT · TypeScript
camelToKebab
f5/unovis · packages/mcp/src/codegen/index.ts:36
const camelToKebab = (name: string): string =>
name.replace(/([a-z0-9])([A-Z])/g, '$1-$2').replace(/([A-Z])([A-Z][a-z])/g, '$1-$2').toLowerCase()
/** JSON with single-quoted strings, matching the repo's code style */
// eslint-disable-next-line @typescript-eslint/no-use-before-define
const json = (value: unknown, spaces = 2): string => requote(JSON.stringify(value, null, spaces))
/** Swap JSON's double quotes for single quotes. Works on the already-escaped
* string bodies, so `\n`, `\u2028` and friends survive untouched; a string
* that itself contains a single quote keeps its double quotes (the
* `avoidEscape` style) instead of growing backslashes. The scan is a single
* pass — JSON.stringify output is well-formed, but the data inside it is
* caller-supplied. */
function requote (jsonText: string): string {
let out = ''
let i = 0
while (i < jsonText.length) {
if (jsonText[i] !== '"') {