# pump-chain

> A module that glues pump and bubble-stream-error to make things easier when your public API returns a stream.

Latest version **1.0.0** (published 2015-11-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install pump-chain
pnpm add pump-chain
yarn add pump-chain
bun add pump-chain
```

## 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.0 |
| Published | 2015-11-27 |
| First published | 2015-11-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Author | Alexandru Vladutu |
| Maintainers | alessioalex |

## Links

- npm: https://www.npmjs.com/package/pump-chain
- Repository: https://github.com/alessioalex/pump-chain
- Homepage: https://github.com/alessioalex/pump-chain#readme
- Issues: https://github.com/alessioalex/pump-chain/issues
- npm.io page: https://npm.io/package/pump-chain

## Dependencies (3)

- [pump](https://npm.io/package/pump.md) ^1.0.1
- [sliced](https://npm.io/package/sliced.md) ^1.0.1
- [bubble-stream-error](https://npm.io/package/bubble-stream-error.md) ^1.0.0

## Recent versions

- 1.0.0 (latest) — 2015-11-27

## README

# pump-chain

A module that glues [pump](http://npm.im/pump) and [bubble-stream-error](http://npm.im/bubble-stream-error) to make life easier when piping streams internally and returning an outer stream.

[![build status](https://secure.travis-ci.org/alessioalex/pump-chain.png)](http://travis-ci.org/alessioalex/pump-chain)

## what problem does it solve?

Consider the situation when you are piping multiple streams internally and returning an outer stream.
That stream will be handled by users of your module so you need to make sure that the errors coming from the internal streams propagate to the outer one (which `bubble-stream-error` takes care of), otherwise they can't be caught and will blow up the process.
Also if one of the inner streams closes you want to make sure that the others get closed as well (which `pump` does).

## usage

Simply pass the streams you want to pipe together to `pump-chain`.

```js
var pump = require('pump-chain');
var crypto = require('crypto');
var fs = require('fs');
var zlib = require('zlib');

function getEncryptedCompressedWordsStream() {
  var gzip = zlib.createGzip();
  var password = new Buffer('car cat tree fireman');
  var aes = crypto.createCipher('aes-256-cbc', password);

  var rs = fs.createReadStream('/usr/share/dict/words');

  // uncomment to simulate an error
  /*
  var i = 0;
  rs.on('data', function() {
    if (++i === 3) {
      this.emit('error', new Error('3 is unlucky!'));
    }
  });
  */

  return pump(rs, aes, gzip);
}

getEncryptedCompressedWordsStream().on('error', function handleError(err) {
  console.error('\n!!! something bad happened while streaming stuff !!!\n');
  throw err;
}).pipe(process.stdout);
```

## tests

```bash
npm test
```

## related

[mississippi stream utility collection](https://github.com/maxogden/mississippi) which includes more useful stream modules similar to this one

## license

[MIT](http://alessioalex.mit-license.org/)

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