chunked-buffer

0.0.6 • Public • Published

chunked-buffer

Downloads

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.
})

Package Sidebar

Install

npm i chunked-buffer

Weekly Downloads

0

Version

0.0.6

License

MIT

Unpacked Size

2.18 kB

Total Files

3

Last publish

Collaborators

  • afterburn