function(head, row, req, row_info) { csv_row = function(arr) { return ['"' + item + '"' for each (item in arr)].join(',') + '\n'; } if (head) { return { headers: { 'Content-Type': 'text/csv' }, body: csv_row(['Titel', 'URL', 'Categoriƫn', 'Tags']) }; } else if (row) { doc = row.value; return csv_row([doc.title, doc.url, doc.categories.join(','), doc.tags.join(',')]); } }