readable-buffer-stream
v2.0.2
Published
Create readable stream which stores data in Buffer
Downloads
4
Readme
readable-buffer-stream
Create readable stream which stores data in Buffer.
Installation
npm install readable-buffer-stream
Usage
'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'))
API
BufferStream({initialSize, chunkSize, incrementSize})
- 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
.
bufferStream.put(chunk)
- buffer:
Buffer
data to be put in thebufferStream
.
Put chunk
in the inner buffer.
bufferStream.stop()
Stop the bufferStream
.