export default class { constructor(rows) { this.rows = rows; } download() { // XXX: should escape various things, but the quick-n-dirty // calls. const data = 'sequence 1,sequence 2,identity\r\n' + this.rows.map(row => row.join(',')).join('\r\n'); const file = new Blob([data], { type: 'text/csv' }) let a = document.createElement('a'); const url = URL.createObjectURL(file); a.href = url; a.download = 'filename.csv'; document.body.appendChild(a); a.click(); setTimeout(_ => { document.body.removeChild(a); URL.revokeObjectURL(url); }, 0); } }