Transforms arrays into equivalent CSV strings. Conforms to RFC 4180, with the exception that, instead of CRLF
, LF
is used as line delimiter.
const csv = require('minimal-csv-formatter');
let singleRow = csv(['x', 'y']);
// 'x,y\n'
let multipleRows = csv([
[1, 2],
[3, 4],
]);
// '1,2\n3,4\n'
let emptyFields = csv([null, undefined]);
// ',\n'
let emptyRows = csv([
[],
null,
undefined,
]);
// ''