# @guanghechen/stream

> Utilities for handing node streams.

Latest version **2.0.5** (published 2026-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @guanghechen/stream
pnpm add @guanghechen/stream
yarn add @guanghechen/stream
bun add @guanghechen/stream
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 2.0.5 |
| Published | 2026-09-12 |
| First published | 2023-10-04 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 33.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | guanghechen |
| Maintainers | lemonclown |
| Keywords | stream, concat streams, merge streams |

## Links

- npm: https://www.npmjs.com/package/@guanghechen/stream
- Repository: https://github.com/guanghechen/sora/tree/@guanghechen/stream@2.0.5
- Homepage: https://github.com/guanghechen/sora/tree/@guanghechen/stream@2.0.5/packages/stream#readme
- npm.io page: https://npm.io/package/@guanghechen/stream

## Dependencies (1)

- [@guanghechen/byte](https://npm.io/package/@guanghechen/byte.md) ^2.0.5

## 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

- 2.0.5 (latest) — 2026-09-12
- 2.0.4 — 2026-07-10
- 2.0.3 — 2026-05-24
- 2.0.2 — 2026-02-15
- 2.0.1 — 2026-02-07
- 2.0.0 — 2026-02-04
- 1.0.3 — 2024-10-03
- 1.0.2 — 2024-09-28
- 1.0.1 — 2024-09-25
- 1.0.0 — 2024-09-20
- 1.0.0-alpha.12 — 2024-09-18
- 1.0.0-alpha.11 — 2024-02-03
- 1.0.0-alpha.10 — 2024-01-02
- 1.0.0-alpha.9 — 2023-12-10
- 1.0.0-alpha.8 — 2023-11-29
- … 7 more at https://npm.io/package/@guanghechen/stream/versions

## README

<header>
  <h1 align="center">
    <a href="https://github.com/guanghechen/sora/tree/@guanghechen/stream@2.0.5/packages/stream#readme">@guanghechen/stream</a>
  </h1>
  <div align="center">
    <a href="https://www.npmjs.com/package/@guanghechen/stream">
      <img
        alt="Npm Version"
        src="https://img.shields.io/npm/v/@guanghechen/stream.svg"
      />
    </a>
    <a href="https://www.npmjs.com/package/@guanghechen/stream">
      <img
        alt="Npm Download"
        src="https://img.shields.io/npm/dm/@guanghechen/stream.svg"
      />
    </a>
    <a href="https://www.npmjs.com/package/@guanghechen/stream">
      <img
        alt="Npm License"
        src="https://img.shields.io/npm/l/@guanghechen/stream.svg"
      />
    </a>
    <a href="#install">
      <img
        alt="Module Formats: cjs"
        src="https://img.shields.io/badge/module_formats-cjs-green.svg"
      />
    </a>
    <a href="https://github.com/nodejs/node">
      <img
        alt="Node.js Version"
        src="https://img.shields.io/node/v/@guanghechen/stream"
      />
    </a>
    <a href="https://github.com/facebook/jest">
      <img
        alt="Tested with Jest"
        src="https://img.shields.io/badge/tested_with-jest-9c465e.svg"
      />
    </a>
    <a href="https://biomejs.dev/">
      <img
        alt="Code Style: Biome"
        src="https://img.shields.io/badge/code_style-biome-60a5fa.svg?style=flat-square"
      />
    </a>
  </div>
</header>
<br/>

Utilities for handling node streams.

## Install

- npm

  ```bash
  npm install --save @guanghechen/stream
  ```

- yarn

  ```bash
  yarn add @guanghechen/stream
  ```

## Usage

|       Name       |                        Description                         |
| :--------------: | :--------------------------------------------------------: |
| `concatStreams`  |      Concatenate readable streams to async iterator.       |
| `consumeStream`  |                  Consume readable stream.                  |
| `consumeStreams` |             Consume multiple streams serially.             |
|  `mergeStreams`  | Merge multiple readable streams into one readable streams. |
| `stream2buffer`  |  Consume read stream and encode the contents into buffer.  |
| `stream2bytes`   |   Consume read stream and encode the contents into bytes.  |

## Example

- Basic.

  ```typescript
  import { consumeStreams } from '@guanghechen/stream'
  import fs from 'node:fs'

  const filepaths = ['a.txt', 'b.txt', 'c.txt']
  const readers: NodeJS.ReadableStream[] = filepaths.map(fp => fs.createReadStream(fp))
  const writer: NodeJS.WritableStream = fs.createWriteStream('out.txt')
  await consumeStreams(readers, writer)
  ```

- Middlewares, i.e., cipher data before output.

  ```typescript
  import { consumeStreams } from '@guanghechen/stream'
  import crypto from 'crypto'
  import fs from 'node:fs'

  const filepaths = ['a.txt', 'b.txt', 'c.txt']
  const readers: NodeJS.ReadableStream[] = filepaths.map(fp => fs.createReadStream(fp))
  const writer: NodeJS.WritableStream = fs.createWriteStream('out.txt')

  const iv: Buffer = crypto.randomBytes(32)
  const key: Buffer = crypto.randomBytes(32)
  const cipher: crypto.Cipher = crypto.createCipheriv('aes-256-gcm', key, iv)
  await consumeStreams(readers, writer, cipher)
  ```

## Reference

- [homepage][homepage]

[homepage]:
  https://github.com/guanghechen/sora/tree/@guanghechen/stream@2.0.5/packages/stream#readme

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