csv-homie
v0.6.4
Published
CSV manager
Downloads
30
Maintainers
Readme
CSV manager
Friendly manager for CSV.
Example
import { stringify } from 'csv-homie';
const dataArray = [
['a', 'b', 'c', 'd'],
[1, 2, null, 4],
[5, 6, 7, 8],
];
// with default options - 2th parameter
stringify(dataArray);
// 'a,b,c,d\n1,2,,4\n5,6,7,8'
const dataCollection = [
{ a: 'b', c: 'd', x: undefined, y: '' },
{ a: 'f', c: 0, x: null, y: NaN },
];
// custom options - 2th parameter
stringify(dataCollection, {
headers: false,
delimiter: '|',
isEmptyIfNullable: false,
});
// 'b|d||\nf|0|null|null'
API
2th parameter, default values commented.
interface IOptions {
headers: boolean; // true
isEmptyIfNullable: boolean; // true
delimiter: string; // ','
}
Dev
npm ci
npm test