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

https://github.com/caub/as-buffer

Convert a stream (or string, array) to buffer
https://github.com/caub/as-buffer

Last synced: 3 months ago
JSON representation

Convert a stream (or string, array) to buffer

Awesome Lists containing this project

README

          

## Read stream and other types as buffer\*
[![npm version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![coverage status][codecov-image]][codecov-url]

```js
const read = require('as-buffer');

const stream = fs.createReadStream('./photo.png');

read(stream, { maxsize: 1e6 }) // with a max-size, default to 1e7, 10MiB
.then(buf => console.log('read', buf))
.catch(e => console.log('file too large'));

```
\*: exception of object-mode streams that are returned as array

like https://github.com/stream-utils/stream-to-array but simpler

[npm-image]: https://img.shields.io/npm/v/as-buffer.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/as-buffer
[travis-image]: https://img.shields.io/travis/caub/as-buffer.svg?style=flat-square
[travis-url]: https://travis-ci.org/caub/as-buffer
[codecov-image]: https://img.shields.io/codecov/c/github/caub/as-buffer.svg?style=flat-square
[codecov-url]: https://codecov.io/gh/caub/as-buffer