import {parseAsync} from 'json2csv'; import flatten from './flatten'; export default function csv(input: any[], f: (err, data) => void) { parseAsync(input.map(e => flatten(e)), {includeEmptyRows: true}) .then(csv => f(null, csv)) .catch(err => f(err, null)); }