INNER CODE UNIT · TypeScript
i
f5/unovis · packages/mcp/src/codegen/index.ts:62
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(', ')} },`
})
return `[\n${rows.join('\n')}\n]`
}
/** Values that are safe to inline; anything larger is referenced by import */