Create a transform stream using await instead of callbacks
MIT License
Create a transform stream using await instead of callbacks
The built-in stream.Transform
constructor forces you to deal with a callback interface. It's much nicer to just be able to await and return a value.
This package can be thought of as a modern version of through2
.
npm install easy-transform-stream
import transformStream from 'easy-transform-stream';
const stream = transformStream(async chunk => {
const newChunk = await modifyChunk(chunk);
return newChunk;
});
Type: Async function
Receives each chunk and is expected to return a transformed chunk.
Type: Async generator function
Yield additional chunks at the end of the stream.
Type: object
Same as the options for stream.Transform
, except for transform
and flush
.