Create readable stream which stores data in Buffer.
npm install readable-buffer-stream
'use strict'
const BufferStream = require('readable-buffer-stream')
let bufferStream = new BufferStream()
bufferStream.on('data', (data) => {
console.log(Buffer.isBuffer(data)) // true
})
bufferStream.put(new Buffer('buffer'))
bufferStream.put(new Buffer('another buffer'))
- initialSize:
Number
initial size of inner buffer. - chunkSize:
Number
size of data in eachdata
event. - incrementSize:
Number
size to increase when inner buffer do not have enough size.
Create a instance of BufferStream
, which extends stream.Readable
.
- buffer:
Buffer
data to be put in thebufferStream
.
Put chunk
in the inner buffer.
Stop the bufferStream
.