Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

structured-stream-writer

1.0.0 • Public • Published

StructuredStreamWriter

A utility for stream-writing CSV and JSON files.

npm CodeFactor Build Status codecov NPM License

Usage

npm i structured-stream-writer
import { StructuredStreamWriter, StructuredFormat } from 'structured-stream-writer';
const sswJSON = new StructuredStreamWriter(StructuredFormat.JSON, outPath);
 
await sswJSON.writeItem({
    item: 1,
    text: 'hello',
});
 
sswJSON.done();
 
console.log(
    readFileSync(outPath, 'UTF8'),
);
/*
*  [{item:1,text:"hello"}]
*/
 
const sswCSV = new StructuredStreamWriter(StructuredFormat.CSV, outPath, ['item', 'text']);
 
await sswCSV.writeItem({
    item: 1,
    text: 'hello',
});
 
sswCSV.done();
 
console.log(
    readFileSync(outPath, 'UTF8'),
);
/* 
*  item,text
*  1,hello
*/

Used By

License - MIT

./LICENSE

Keywords

none

Install

npm i structured-stream-writer

DownloadsWeekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

15.5 kB

Total Files

14

Last publish

Collaborators

  • avatar