INNER CODE UNIT · TypeScript
indent
f5/unovis · packages/mcp/src/codegen/index.ts:33
const indent = (text: string, spaces: number): string =>
text.split('\n').map(line => (line ? ' '.repeat(spaces) + line : line)).join('\n')
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 = ''