# then-streams

> Node.js Streams in Promise

Latest version **1.0.1** (published 2019-02-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install then-streams
pnpm add then-streams
yarn add then-streams
bun add then-streams
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2019-02-20 |
| First published | 2019-02-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=6.0.0 |
| Dependencies | 0 |
| Unpacked size | 9.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | OnikurYH |
| Maintainers | onikuryh |

## Links

- npm: https://www.npmjs.com/package/then-streams
- Repository: https://github.com/OnikurYH/then-streams
- npm.io page: https://npm.io/package/then-streams

## Recent versions

- 1.0.1 (latest) — 2019-02-20
- 1.0.0 — 2019-02-20

## README

# then-streams

> Convert Node.js Streams to Promise

[![Build Status](https://travis-ci.com/OnikurYH/then-streams.svg?branch=master)](https://travis-ci.com/OnikurYH/then-streams)

## Example

This package is written in TypeScript, also can work on JavaScript!

**Writable Stream**

```ts
import fs from 'fs';
import thenStreams from 'then-streams';

async function readFileToConsole() {
  const stream = fs.createReadStream('some-file.txt')
    .pipe(process.stdout);
  await thenStreams.toPromise(stream);
  console.log('The file has finished reading and pipe to console');
}
```

**Readable Stream**

```ts
import fs from 'fs';
import thenStreams from 'then-streams';

  async function readFileAndCollect() {
    const data = [];
    const stream = fs.createReadStream('some-file.txt')
      .on('data', d => data.push(d));
    await thenStreams.toPromise(stream);
  }
```

## Run test

You could run the tests from the `test` folder

```bash
yarn install
yarn test
```

## Copyright and license

Licensed under [the MIT license](LICENSE).

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