@calipsa/array-to-csv
v1.1.1
Published
Convert array to CSV
Downloads
112
Readme
@calipsa/array-to-csv
Installation
# using npm:
npm install --save @calipsa/array-to-csv
# or if you like yarn:
yarn add @calipsa/array-to-csv
Usage
import arrayToCsv from '@calipsa/array-to-csv'
const columns = [
'col1',
'col2',
{
key: 'col3',
label: 'Column 3',
},
{
key: 'col4',
label: 'Column 4 (uppercase)',
transform: (val) => val.toUpperCase(),
},
]
// get the converter
const toCsv = arrayToCsv(columns)
// get the csv
const result = toCsv(list)
console.log(result)