buffer-to-stream
Convert buffer or string to readable stream.
Usage
const toStream = require('buffer-to-stream')
const readable = toStream(Buffer.from('hello world!', 'utf8'))
readable.on('readable', () => {
let chunk
while ((chunk = reader.read()) !== null) {
console.log('got data', chunk)
}
})
readable.on('end', () => console.log('done'))
API
toStream(buffer[, chunkSize])
buffer
is the source buffer or string, and the type is String|Buffer
.chunkSize
specifies stream data push chunk size, and type is Number
.
And the return value is a readable stream.
License
MIT