buffer-to-stream
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/buffer-to-stream package

1.0.0 • Public • Published

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

Dependents (21)

Package Sidebar

Install

npm i buffer-to-stream

Weekly Downloads

6,284

Version

1.0.0

License

MIT

Last publish

Collaborators

  • creeper