Preview:
const file = bucket.file(`${folderName}/${fileName}`)
const passThroughStream = new stream.PassThrough()
passThroughStream.write(fileTitle)
passThroughStream.write(fileHeader)
passThroughStream.write(convertArrayToCSV(accounts.map(mapRecords)))
passThroughStream.end()

passThroughStream
  .pipe(file.createWriteStream())
  .on('error', (err) => {
  console.error(makeLogEntry(err))
})
  .on('finish', () => {
  console.log('writed')
})
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter