@sealsystems/stream-assembler
v1.1.4
Published
Assemble data from multiple read streams into a single write stream.
Downloads
6
Readme
@sealsystems/stream-assembler
Assemble data from multiple read streams into a single write stream.
Installation
npm install @sealsystems/stream-assembler
Quick start
First you need to add a reference to @sealsystems/stream-assembler
within your application.
const Assembler = require('@sealsystems/stream-assembler');
Then you can create an assembler object.
const assembler = new Assembler(readables);
API
constructor(readables[, options])
readables
<array> | <function> Creates an object of typeAssembler
.options
<Object> Pipe optionsend
<boolean> End the writer after all readers end. Defaults to true.
The readables
array has to contain objects implementing the stream.Readable
interface.
The readables
function has to be either a synchronous or an async
function for which the assembler object can await
for. The function is called without any parameter and has to return the next read stream at each call or null if no read streams left.
assembler.pipe(writeable)
writeable
<stream.Writeable> The destination for writing data.
Throws on error and returns null on success.
The pipe
function attaches the writeable
stream to all readable streams one at a time in the order the readable streams are given.
const assembler = new Assembler(readables);
await assembler.pipe(writeable);