INNER CODE UNIT · TypeScript
end
f5/unovis · packages/mcp/src/codegen/index.ts:58
let end = i + 1
while (end < jsonText.length && jsonText[end] !== '"') end += jsonText[end] === '\\' ? 2 : 1
const body = jsonText.slice(i + 1, end)
out += body.includes("'") ? `"${body}"` : `'${body.replace(/\\"/g, '"')}'`
i = end + 1
}
return out.replace(/'([A-Za-z_$][\w$]*)':/g, '$1:') // unquote plain object keys
}
/** One record per line — readable for the dozens of rows charts usually carry */
function dataLiteralFor (data: unknown): string {
if (!Array.isArray(data)) return json(data)
const rows = data.map(record => {
if (typeof record !== 'object' || record === null) return ` ${json(record, 0)},`
const fields = Object.entries(record)
.map(([key, value]) => `${/^[A-Za-z_$][\w$]*$/.test(key) ? key : json(key)}: ${json(value, 0)}`)
return ` { ${fields.join(', ')} },`
})