buffer-to-stream
v1.0.0
Published
convert buffer to readable stream
Downloads
42,019
Readme
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 isString|Buffer
.chunkSize
specifies stream data push chunk size, and type isNumber
.
And the return value is a readable stream.