package
Format tabular data from object streams to different (standard) formats
npm install format-dataGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
Module for formatting tabular data from object streams in different standard ways.
Supporting csv, ndjson, json and sse. Install with npm install format-data.
formatData(format, [opts])The opts object will be passed to the underlying serializing module (see below).
or just pass an options object with format as a key.
formatData(opts)You can pass a custom prefix, separator, or suffix to the stream builder for csv and json cases.
Examples:
## default separator for csv is ','
> formatData('csv')
'a,b\n1,2\nhello,world\n'
## change separator to a tab
> formatData({format: 'csv', separator: '\t'})
'a\tb\n1\t2\nhello\tworld\n'
## default object style finishes with }]
> formatData({
format: 'json',
style: 'object'
})
{"rows":[{"a":
Formats and the used modules:
'csv' - require('csv-write-stream')(opts)'ndjson' - require('ndjson').stringify(opts)json - new require('./json.js')(opts)sse - require('ssejson').serialize(opts)maxogden
max@maxogden.com
Estimated unpacked size across 19 packages.
826.1 kB
Includes dependencies.
4 direct · 2 outdated