| /** |
| * Triggers a browser file download of CSV content as a .csv file. |
| * @param filename The name of the file to save (e.g. 'perf-traces.csv') |
| * @param csvContent The CSV text string to download |
| */ |
| export function downloadCSV(filename: string, csvContent: string): void { |
| const blob = new Blob([csvContent], { type: 'text/csv;charset=utf-8;' }); |
| const url = URL.createObjectURL(blob); |
| const a = document.createElement('a'); |
| a.href = url; |
| a.download = filename; |
| a.style.display = 'none'; |
| document.body.appendChild(a); |
| a.click(); |
| document.body.removeChild(a); |
| URL.revokeObjectURL(url); |
| } |