safe-batch-stream
v1.0.2
Published
Safely creates an array of elements inside a stream. It prevents [backpressuring in streams](https://nodejs.org/es/docs/guides/backpressuring-in-streams/) by waiting the drain after reaching a limit of batches built
Downloads
6
Maintainers
Readme
safe-batch-stream
Safely creates an array of elements inside a stream. It prevents backpressuring in streams by waiting the drain after reaching a limit of batches built
Example
import { SafeBatchStream } from 'safe-batch-stream';
// Default batch size 1
// Default batch limit 1
const safeBatchStream = new SafeBatchStream();
const writable = new Writable({
objectMode: true, // required to the next writable after safeBatchStream
write: (chunk, encoding, callback) => {
// Do someting
}
})
sourceStream
.pipe(safeBatchStream)
.pipe(writable);