chunked-buffer
v0.0.6
Published
Small function you can wrap fs.createReadStream with to get fixed size data chunks
Downloads
5
Maintainers
Readme
chunked-buffer
Small function you can wrap fs.createReadStream with to get fixed size data chunks.
chunked-buffer modifies stream.Readable's 'data' event to make it so that chunks will have a fixed amount of bytes instead of getting randomly sized chunks. This can be extremely helpful if the target you pipe to expects a certain amount of bytes or if that target has a byte limitation (a udp packet for example).
Usage
const chunked = require('chunked-buffer')
const rs = chunked(fs.createReadStream('path/to/file'), { chunkSize: 20000 })
rs.on('data', (chunk) => {
// chunk is a Buffer with a size of 20000 bytes.
})