# stream-connect

> Connects an arbitrary number of streams into a single, combined stream

Latest version **1.0.2** (published 2016-01-04) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

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

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2016-01-04 |
| First published | 2015-06-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Lloyd Brookes |
| Maintainers | 75lb |
| Keywords | connect, combine, stream, streams, transform |

## Links

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

## Dependencies (1)

- [array-back](https://npm.io/package/array-back.md) ^1.0.2

## 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.2 (latest) — 2016-01-04
- 1.0.1 — 2016-01-01
- 1.0.0 — 2016-01-01
- 0.2.4 — 2015-12-26
- 0.2.3 — 2015-12-26
- 0.2.2 — 2015-12-26
- 0.2.1 — 2015-12-25
- 0.2.0 — 2015-12-25
- 0.1.0 — 2015-06-28

## README

[![view on npm](http://img.shields.io/npm/v/stream-connect.svg)](https://www.npmjs.org/package/stream-connect)
[![npm module downloads](http://img.shields.io/npm/dt/stream-connect.svg)](https://www.npmjs.org/package/stream-connect)
[![Build Status](https://travis-ci.org/75lb/stream-connect.svg?branch=master)](https://travis-ci.org/75lb/stream-connect)
[![Coverage Status](https://coveralls.io/repos/75lb/stream-connect/badge.svg?branch=master&service=github)](https://coveralls.io/github/75lb/stream-connect?branch=master)
[![Dependency Status](https://david-dm.org/75lb/stream-connect.svg)](https://david-dm.org/75lb/stream-connect)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](https://github.com/feross/standard)

# stream-connect

Similar to `.pipe` except `.pipe` returns the last stream in a pipeline. stream-connect returns a stream which writes to the first stream in the pipeline and reads from the last.

## Synopsis

```js
const connect = require('stream-connect')
const fs = require('fs')

const connected = connect(stream1, stream2, stream3, stream4)

// data piped into the connected stream is transparently passed through all four internal streams
// then output into process.stdout. Errors in any of the internal streams are emitted
// by the connected stream.
process.stdin
  .pipe(connected)
  .on('error', console.error)
  .pipe(process.stdout)
```

## More detail

Consider this `.pipe` example.

```js
function getExampleStream () {
 ...
 return streamOne.pipe(streamTwo)
}
const stream = getExampleStream()
stream.on('data', function (chunk) {}) // catches data from streamOne via streamTwo
stream.on('error', function (err) {}) // catches errors only from streamTwo
stream.end('test') // is written to streamTwo
```

If you write to the output it will be written to `streamTwo`, whereas you probably wanted to write to the  start of the pipeline and read from the end. Fixed by stream-connect:

```js
const connect = require('stream-connect')
function getExampleStream () {
 ...
 return connect(streamOne, streamTwo)
}
const stream = getExampleStream()
stream.on('data', function (chunk) {}) // catches data from streamOne via streamTwo
stream.on('error', function (err) {}) // catches errors from both streamOne and streamTwo
stream.end('test') // is written to streamOne
```

Any errors emitted in `streamOne` or `streamTwo` are propagated to the output stream.

<a name="module_stream-connect"></a>
## stream-connect
**Example**  
```js
const connect = require('stream-connect')
```
<a name="exp_module_stream-connect--connect"></a>
### connect(...streams) ⇒ <code>[Duplex](https://nodejs.org/api/stream.html#stream_class_stream_duplex)</code> ⏏
Connect streams.

**Kind**: Exported function  

| Param | Type | Description |
| --- | --- | --- |
| ...streams | <code>[Duplex](https://nodejs.org/api/stream.html#stream_class_stream_duplex)</code> | One or more streams to connect. |


* * *

&copy; 2015 Lloyd Brookes \<75pound@gmail.com\>. Documented by [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown).

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