accumulate-stream
Useful implementations for writable stream
Installation
$ npm i -S accumulate-stream
$ yarn add accumulate-stream
Usage
import { createReadStream } from 'fs';
import { once } from 'events';
import { AccumulateStream, RotateStream, DomainStream, DOMAIN_EVENT, ROTATE_EVENT } from 'accumulate-stream';
(async (): void => {
const readable = createReadStream('file.txt');
const acc = new AccumulateStream();
const rot = new RotateStream({ size: '1kb', count: 2 });
const dom = new DomainStream('accumulate-stream');
readable.pipe(acc);
readable.pipe(rot);
readable.pipe(dom);
rot.on(ROTATE_EVENT, () => console.log(rot.getContent().toString()));
await once(dom, DOMAIN_EVENT);
console.log(acc.getContent().toString());
})();
[TBD]: API