# streamcat

> Concatenate ReadStreams and Buffers!

Latest version **2.6.5** (published 2020-11-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install streamcat
pnpm add streamcat
yarn add streamcat
bun add streamcat
```

## 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 | 2.6.5 |
| Published | 2020-11-10 |
| First published | 2015-05-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 20.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | samgiles, the-ft |
| Keywords | streams, concatenation, read, buffer |

## Links

- npm: https://www.npmjs.com/package/streamcat
- Repository: github.com/Financial-Times/streamcat
- Homepage: https://github.com/Financial-Times/streamcat
- Issues: https://github.com/Financial-Times/streamcat/issues
- npm.io page: https://npm.io/package/streamcat

## Dependencies (1)

- [promisebuffer](https://npm.io/package/promisebuffer.md) ^1.0.0

## 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.6.5 (latest) — 2020-11-10
- 2.6.4 — 2020-06-03
- 2.6.0 — 2015-06-08
- 2.5.0 — 2015-06-05
- 2.4.1 — 2015-06-01
- 2.4.0 — 2015-05-21
- 2.3.1 — 2015-05-20
- 2.3.0 — 2015-05-20
- 2.2.3 — 2015-05-19
- 2.2.2 — 2015-05-19
- 2.2.1 — 2015-05-19
- 2.2.0 — 2015-05-19
- 2.1.0 — 2015-05-19
- 2.0.0 — 2015-05-11
- 1.0.2 — 2015-05-06
- … 1 more at https://npm.io/package/streamcat/versions

## README

# streamcat

Concatenate Node JS Streams!

You can concatenate the result of Promises, non async buffers and other
streams allowing you to sequence things into an asynchronous Stream.

## Usage

Example, print the contents of `myfileA` followed by `myfileB`, this is
equivalent to using `cat(1)`: `cat myfileA myfileB`.

```JS
var streamCat = require('streamcat');

streamCat([
	fs.createReadStream('myfileA'),
	fs.createReadStream('myfileB')
]).pipe(process.stdout);
```

### API

#### `streamCat(listOfStreamsBuffersOrPromises)`

`streamCat` will take a list of `ReadStream`s, `Buffer`s, or `Promise`s
returning a `ReadStream` or `Buffer` as its only
argument and returns a `ReadStream` that will stream the concatenation of each
item in the list.

You can mix `Buffer`, `ReadStream`, and `Promise` usage, in this instance, the `String`
`"Some content"` will be streamed between `myfileA` and `myfileB`:

```JS
streamCat([
	fs.createReadStream('myfileA'),
	new Buffer("Some content"),
	fs.createReadStream('myfileB')
]).pipe(process.stdout);
```

Example using `Promise`s that has the same result as the above example, the
value in the `Promise` is resolved asynchronously:

```JS
streamCat([
	fs.createReadStream('myfileA'),
	Promise.resolve(new Buffer("Some content")),
	fs.createReadStream('myfileB')
]).pipe(process.stdout);

```

#### Error Handling

The `streamCat` function can take an optional options object as its second
argument.

##### `errorMapper`

The `errorMapper` option allows you to specify a function that can transform
an error from any of the contatenated streams before emitting the error on the
returned stream.

The `errorMapper` must return an error object.

```JS
{
	errorMapper: function(error) {
		error.message = error.message + ": my custom context";
		return error;
	}
}
```

## License

MIT

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