Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/creeperyang/buffer-to-stream

Convert buffer to readable stream.
https://github.com/creeperyang/buffer-to-stream

buffer buffer-to-stream convert-buffer-to-stream stream

Last synced: 2 months ago
JSON representation

Convert buffer to readable stream.

Awesome Lists containing this project

README

        

[![Build Status](https://travis-ci.org/creeperyang/buffer-to-stream.svg?branch=master)](https://travis-ci.org/creeperyang/buffer-to-stream)
[![npm version](https://badge.fury.io/js/buffer-to-stream.svg)](https://badge.fury.io/js/buffer-to-stream)
[![Dependency Status](https://david-dm.org/creeperyang/buffer-to-stream.svg)](https://david-dm.org/creeperyang/buffer-to-stream)

# buffer-to-stream

> Convert buffer or string to readable stream.

[![NPM](https://nodei.co/npm/buffer-to-stream.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/buffer-to-stream/)

## Usage

```js
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](/LICENSE)