# stream-composer

> Modern stream composer

Latest version **1.0.2** (published 2023-06-01) · MIT license · 0 weekly downloads

## Install

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

## 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.2 |
| Published | 2023-06-01 |
| First published | 2023-05-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 12.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12 |
| Author | Mathias Buus |
| Maintainers | mafintosh |

## Links

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

## Dependencies (1)

- [streamx](https://npm.io/package/streamx.md) ^2.13.2

## Recent versions

- 1.0.2 (latest) — 2023-06-01
- 1.0.1 — 2023-06-01
- 1.0.0 — 2023-05-21
- 0.0.0 — 2023-05-21

## README

# stream-composer

Modern stream composer

```
npm install stream-composer
```

Supports composing and pipelining multiple streams into a single [streamx](https://github.com/mafintosh/streamx) stream.

## Usage

``` js
const Composer = require('stream-composer')

// Make a duplex stream out of a read and write stream
const stream = new Composer()

stream.setReadable(someReadableStream) // set readable side
stream.setWritable(someWritableStream) // set writable side

// reads, read from the readable stream
stream.on('data', function (data) {
  // data is from someReadableStream
})

// writes, write to the writable stream
stream.write(data)
```

## API

#### `stream = new Composer([options])`

Make a new composer. Optionally pass the writable stream and readable stream in the constructor.
Options are forwarded to streamx.

#### `stream.setReadable(readableStream)`

Set the readable stream. If you pass `null` the readable stream will be set to an empty stream for you.

#### `stream.setWritable(writableStream)`

Set the writable stream. If you pass `null` the writable stream will be set to an empty stream for you.

#### `stream.setPipeline(...pipelineStreams)`

Set the stream to a pipeline. Writing to the outer stream writes to the first stream in the pipeline
and reading from the outer stream, reads from the last stream in the pipeline.

#### `stream = Composer.pipeline(...pipelineStreams)`

Helper for making a composer stream and setting the pipeline in one go.

#### `stream = Composer.duplexer(writableStream, readableStream)`

Helper for making a composer stream and setting the writable and readable stream in one go.

## License

MIT

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