# stream-promise

> Promise that shares Node.js Stream interface

Latest version **3.2.0** (published 2019-03-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install stream-promise
pnpm add stream-promise
yarn add stream-promise
bun add stream-promise
```

## 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 | 3.2.0 |
| Published | 2019-03-15 |
| First published | 2015-06-02 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 12 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Mariusz Nowak |
| Maintainers | cwmma |
| Keywords | promise, stream, emitter, event-emitter |

## Links

- npm: https://www.npmjs.com/package/stream-promise
- Repository: https://github.com/medikoo/stream-promise
- Homepage: https://github.com/medikoo/stream-promise#readme
- Issues: https://github.com/medikoo/stream-promise/issues
- npm.io page: https://npm.io/package/stream-promise

## Dependencies (3)

- [es5-ext](https://npm.io/package/es5-ext.md) ^0.10.49
- [is-stream](https://npm.io/package/is-stream.md) ^1.1.0
- [2-thenable](https://npm.io/package/2-thenable.md) ^1.0.0

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 3.2.0 (latest) — 2019-03-15
- 3.1.0 — 2019-01-17
- 3.0.0 — 2019-01-17
- 2.0.0 — 2019-01-15
- 1.0.0 — 2015-06-02

## README

[![*nix build status][nix-build-image]][nix-build-url]
[![Windows build status][win-build-image]][win-build-url]
[![Tests coverage][cov-image]][cov-url]
![Transpilation status][transpilation-image]
[![npm version][npm-image]][npm-url]

# stream-promise

## Convert any [Stream](https://nodejs.org/api/stream.html#stream_stream) instance to thenable

So it can be consumed both as a promise and as a stream

### Installation

```bash
npm install stream-promise
```

# Usage

Stream must be either readable or writable.

In case of readable streams, promise resolves with concatenated output, in case of writable streams resolve with `undefined`

To achieve expected result stream should be converted immediately after initialization.

```javascript
const streamPromise = require("stream-promise");

streamPromise(someReadableStream);

someReadableStream.then(result => { console.log("Concatenated stream output", result); });

streamPromise(someWritabletream);

someReadableStream.then(result => { console.log("Cumulated stream output", result); });
```

Already emitted data is accessible at `emittedData` property

## Non-destructive way

Sepearate promise (without touching stream object) can be created with `to-promise` util:

```javascript
const streamToPromise = require("stream-promise/to-promise");

const someReadableStreamPromise = streamPromiseTo(someReadableStream);

someReadableStreamPromise.then(result => { console.log("Concatenated stream output", result); });
```

## Supported options

### noCollect `boolean` (default: `false`)

Applicable to _readable_ streams. Set to true, if it's not intended to gather stream result and resolve with it.

Then the only purpose of promise would be to indicate a moment when data stream is finalized

### Tests

```bash
npm test
```

[nix-build-image]: https://semaphoreci.com/api/v1/medikoo-org/stream-promise/branches/master/shields_badge.svg
[nix-build-url]: https://semaphoreci.com/medikoo-org/stream-promise
[win-build-image]: https://ci.appveyor.com/api/projects/status/2ihsys269r29l2ol?svg=true
[win-build-url]: https://ci.appveyor.com/api/project/medikoo/stream-promise
[cov-image]: https://img.shields.io/codecov/c/github/medikoo/stream-promise.svg
[cov-url]: https://codecov.io/gh/medikoo/stream-promise
[transpilation-image]: https://img.shields.io/badge/transpilation-free-brightgreen.svg
[npm-image]: https://img.shields.io/npm/v/stream-promise.svg
[npm-url]: https://www.npmjs.com/package/stream-promise

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