Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/creeperyang/buffer-to-stream
- Owner: creeperyang
- License: mit
- Created: 2017-08-15T02:59:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-15T08:50:27.000Z (over 7 years ago)
- Last Synced: 2024-10-02T19:35:38.397Z (3 months ago)
- Topics: buffer, buffer-to-stream, convert-buffer-to-stream, stream
- Language: JavaScript
- Size: 50.8 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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)