# promisebuffer

> Utilities for Buffering streamed content into a Promise value.

Latest version **1.0.0** (published 2015-06-08) · 0 weekly downloads

## Install

```sh
npm install promisebuffer
pnpm add promisebuffer
yarn add promisebuffer
bun add promisebuffer
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2015-06-08 |
| First published | 2015-06-08 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | samgiles |

## Links

- npm: https://www.npmjs.com/package/promisebuffer
- npm.io page: https://npm.io/package/promisebuffer

## Recent versions

- 1.0.0 (latest) — 2015-06-08

## README

# Promise Stream Buffer

Utilities for Buffering streamed content into a Promise value.


## API

### `buffer(stream)`

Given a `stream` returns a `Promise` that will resolve with the Buffered
contents of to the Stream once it has been fully written (`end` event
emitted).

Example:

```JS
var buffer = require('promisebuffer');

buffer(require('fs').createReadStream('myfile')).then(function(buffer) {
	console.log(buffer.toString());
}).catch(function(error) {
	console.error(error.message);
});
```

### `bufferStreamError(stream)`

Given a stream buffer the first error that occurs until an event listener is
registered.  This allows you to attach event listeners in a different event
loop run.

Example:

```JS
var bufferError = require('promisebuffer').bufferError;

var stream = bufferError(require('fs').createReadStream('myfile'));

// Allows you to attach error handlers inside async sections without an error
// throwing an uncaught exception
var x = new Promise(function(resolve, reject) {
	stream.on('error', reject);
	/ * ... */
});
```

# License

MIT

---
_Source: https://npm.io/package/promisebuffer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
