ginkgoch-stream-io
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

node-stream-io

A stream reader/writer for nodejs with async methods. No extra lib referenced.

StreamReader

const fs = require('fs');
const { StreamReader } = require('ginkgoch-stream-io') 

const stream = fs.createReadStream(filename, { encoding: 'utf-8' });
async function load(stream) {
    let sr = new StreamReader(stream);
    await sr.open();
    
    let r = undefined;
    while(r = await sr.read(16)) {
        console.log(r);
    }
}

load(stream);

StreamWriter

const fs = require('fs');
const { StreamWriter } = require('ginkgoch-stream-io') 

async function load(stream) {
    const sw = new StreamWriter(stream)
    await sw.writeLine('Content 1')
    await sw.writeLine('Content 2')
    await sw.writeLine('Content 3')
    await sw.end()
}

const stream = fs.createWriteStream(filename, { encoding: 'utf-8' })
load(stream);

Readme

Keywords

none

Package Sidebar

Install

npm i ginkgoch-stream-io

Weekly Downloads

2

Version

1.2.0

License

MIT

Unpacked Size

25.6 kB

Total Files

11

Last publish

Collaborators

  • ginkgoch-dev