(value: unknown)
| 86 | } |
| 87 | |
| 88 | export function escapeCsvValue(value: unknown): string { |
| 89 | if (value === null || value === undefined) return '' |
| 90 | const str = typeof value === 'object' ? JSON.stringify(value) : String(value) |
| 91 | if (str.includes(',') || str.includes('"') || str.includes('\n') || str.includes('\r')) { |
| 92 | return `"${str.replace(/"/g, '""')}"` |
| 93 | } |
| 94 | return str |
| 95 | } |
| 96 | |
| 97 | export function convertRowsToCsv(rows: Record<string, unknown>[]): string { |
| 98 | if (rows.length === 0) return '' |
no test coverage detected