# sandwich-stream

> A readable stream that concatenates multiple streams with optional head, tail & join buffers

Latest version **2.0.2** (published 2018-10-31) · Apache-2.0 license · 0 weekly downloads

## Install

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

## Health

**Score 30/100 (F)** — status: abandoned.

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

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2018-10-31 |
| First published | 2013-08-30 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >= 0.10 |
| Dependencies | 0 |
| Unpacked size | 23.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | connrs |
| Maintainers | connrs |
| Keywords | stream, sandwich, readable, typescript, concatenation |

## Links

- npm: https://www.npmjs.com/package/sandwich-stream
- Repository: https://github.com/connrs/node-sandwich-stream
- Homepage: https://github.com/connrs/node-sandwich-stream#readme
- Issues: https://github.com/connrs/node-sandwich-stream/issues
- npm.io page: https://npm.io/package/sandwich-stream

## 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.2 (latest) — 2018-10-31
- 2.0.1 — 2018-10-30
- 2.0.0 — 2018-10-22
- 1.0.0 — 2015-08-09
- 0.0.4 — 2013-08-31
- 0.0.3 — 2013-08-30
- 0.0.2 — 2013-08-30
- 0.0.1 — 2013-08-30

## README

# SandwichStream

[![npm](https://img.shields.io/npm/v/sandwich-stream.svg?style=flat-square)](https://www.npmjs.com/package/sandwich-stream)
[![npm](https://img.shields.io/npm/dt/sandwich-stream.svg?style=flat-square)](https://www.npmjs.com/package/sandwich-stream)
[![Travis CI](https://img.shields.io/travis/connrs/node-sandwich-stream.svg?style=flat-square)](https://travis-ci.org/connrs/node-sandwich-stream)
[![codecov](https://img.shields.io/codecov/c/github/connrs/node-sandwich-stream.svg?style=flat-square)](https://codecov.io/gh/connrs/node-sandwich-stream)
[![Codacy Badge](https://img.shields.io/codacy/grade/6d64b00364bf413980280bd4e55d6115.svg?style=flat-square)](https://www.codacy.com/project/connrs/node-sandwich-stream/dashboard?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=connrs/node-sandwich-stream&amp;utm_campaign=Badge_Grade_Dashboard)
[![Dependencies](https://david-dm.org/connrs/node-sandwich-stream.svg?style=flat-square)](https://codeclimate.com/github/connrs/node-sandwich-stream/master/package.json)
[![Known Vulnerabilities](https://snyk.io/test/github/connrs/node-sandwich-stream/badge.svg?style=flat-square&targetFile=package.json)](https://snyk.io/test/github/connrs/node-sandwich-stream?targetFile=package.json)
[![Maintainability](https://api.codeclimate.com/v1/badges/a6a00d50601938edfdad/maintainability)](https://codeclimate.com/github/connrs/node-sandwich-stream/maintainability)

## About
While I'm not overjoyed about how performant the internals will operate, I wanted a readable stream that was ACTUALLY A READABLE STREAM. Not a streams1 stream masquerading as streams2. As soon as somebody writes a better concat stream as a readable stream with a nice simple API, this baby is going to develop some serious abandonment issues.

## Installation
```bash
npm install sandwich-stream --save
```

**note**: this code was made using it [TypeScript](https://www.typescriptlang.org/), and its typings are linked in [package.json](./package.json), so there's no need of installing _@types/sandwich-stream_ or anything related. 

## Usage
```typescript
import { SandwichStream } from 'sandwich-stream';
// OR EVEN:
// const SandwichStream = require('sandwich-stream');

const sandwich = SandwichStream({
    head: 'Thing at the top\n',
    tail: '\nThing at the bottom',
    separator: '\n ---- \n'
});

sandwich.add(aStreamIPreparedEarlier)
        .add(anotherStreamIPreparedEarlier)
        .add(aFurtherStreamIPreparedEarlier)
        .pipe(process.stdout);

// The thing at the top
//  ---- 
// Stream1
//  ---- 
// Stream2
//  ---- 
// Stream3
// The thing at the bottom
```
## Configuration Options
* `head` option takes a string/buffer and pushes the string before all other content
* `foot` option takes a string/buffer and pushes the string after all other data has been pushed
* `separator` option pushes a string/buffer between each stream
* [Readable Options](https://github.com/DefinitelyTyped/DefinitelyTyped/blob/be662c475da091788139b486a55708f02e2880b6/types/node/index.d.ts#L6485) can also be passed through.

## API
Too add a stream use the **.add** method: `sandwich.add(streamVariable);`

## More
Wanna known more about Node Streams? Read [this](https://medium.freecodecamp.org/node-js-streams-everything-you-need-to-know-c9141306be93).

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