1.0.0 • Published 5 years ago

structured-stream-writer v1.0.0

Weekly downloads
2
License
MIT
Repository
-
Last release
5 years ago

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