buffer-to-stream

convert buffer to readable stream

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
buffer-to-stream
101.0.06 years ago6 years agoMinified + gzip package size for buffer-to-stream in KB

Readme

Build Status npm version Dependency Status
buffer-to-stream
Convert buffer or string to readable stream.

NPM

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