structured-stream-writer
TypeScript icon, indicating that this package has built-in type declarations

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

Readme

Keywords

none

Package Sidebar

Install

npm i structured-stream-writer

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

15.5 kB

Total Files

14

Last publish

Collaborators

  • isnit0