stream-chunker
A transform stream which chunks incoming data into chunkSize
byte chunks.
api
var chunker = require('stream-chunker')(chunkSize, [flush])
Returns a new chunker. Chunker is a duplex (tansform) stream. You can write data into the
chunker, and regardless of the incoming data, the readable side will emit data
in chunkSize
byte chunks.
chunkSize
: integer
- Size in bytes of the desired chunks.flush
: boolean
- Optional. Flush incomplete chunk data on stream end. Default is false
.
An example
var Lorem = require('loremipstream');
var sampleStream = new Lorem({
size: 1000,
dataSize: 10,
dataInteval: 100
});
var Chunker = require('stream-chunker');
var chunker = Chunker(4);
chunker.on('data', function(data) {
console.log('4 byte chunk: ' + data.toString('utf8'));
});
sampleStream.pipe(chunker);
License
MIT