# p-stream

> Readable stream to Promise

Latest version **1.0.3** (published 2015-11-16) · MIT license · 0 weekly downloads

## Install

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

## 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.3 |
| Published | 2015-11-16 |
| First published | 2015-07-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Miguel Castillo |
| Maintainers | manchagnu |
| Keywords | streams, promise, stream to promise |

## Links

- npm: https://www.npmjs.com/package/p-stream
- Repository: https://github.com/MiguelCastillo/p-stream
- Issues: https://github.com/MiguelCastillo/p-stream/issues
- npm.io page: https://npm.io/package/p-stream

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2015-11-16
- 1.0.2 — 2015-07-13
- 1.0.1 — 2015-07-13
- 1.0.0 — 2015-07-13

## README

# p-stream

> Readable stream to Promise

Create Promises that resolve when a `readable` stream is finished streaming data. Or rejected when the stream reports an error.

> Promise must be polyfilled.

### Examples

``` javascript
var fs = require("fs");
var pstream = require("p-stream");

function readFile(filePath) {
  return fs
    .createReadStream(filePath)
    .setEncoding("utf8");
}

pstream(readFile("somefile.log")).then(function(text) {
  console.log("File read", text);
});
```

> p-stream can handle strings and buffers.

TIP: Make sure to set the encoding on the stream to properly handle utf8 strings. Please refer to [setEncoding ](https://nodejs.org/api/stream.html#stream_readable_setencoding_encoding) for more details.

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