# @utilx/stream

> ```bash npm install @typeshell/stream-utils ```

Latest version **0.0.22** (published 2019-05-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install @utilx/stream
pnpm add @utilx/stream
yarn add @utilx/stream
bun add @utilx/stream
```

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.22 |
| Published | 2019-05-08 |
| First published | 2019-03-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 10 |
| Unpacked size | 36.5 KB |
| Known vulnerabilities | 0 (+37 in 2 direct dependencies) |
| Install scripts | no |
| Maintainers | lteam |

## Links

- npm: https://www.npmjs.com/package/@utilx/stream
- Repository: https://github.com/edwinjhlee/stream-utils
- Homepage: https://github.com/edwinjhlee/stream-utils#readme
- Issues: https://github.com/edwinjhlee/stream-utils/issues
- npm.io page: https://npm.io/package/@utilx/stream

## Dependencies (10)

- [tar](https://npm.io/package/tar.md) ^4.4.8
- [axios](https://npm.io/package/axios.md) ^0.18.0
- [archiver](https://npm.io/package/archiver.md) ^3.0.0
- [unzipper](https://npm.io/package/unzipper.md) ^0.9.11
- [@types/tar](https://npm.io/package/@types/tar.md) ^4.0.0
- [@utilx/promise](https://npm.io/package/@utilx/promise.md) latest
- [@types/archiver](https://npm.io/package/@types/archiver.md) ^2.1.3
- [@types/unzipper](https://npm.io/package/@types/unzipper.md) ^0.9.2
- [@utilx/iterator](https://npm.io/package/@utilx/iterator.md) latest
- [@utilx/semantic](https://npm.io/package/@utilx/semantic.md) latest

## Recent versions

- 0.0.22 (latest) — 2019-05-08
- 0.0.21 — 2019-05-07
- 0.0.20 — 2019-05-07
- 0.0.19 — 2019-05-07
- 0.0.18 — 2019-05-07
- 0.0.17 — 2019-05-07
- 0.0.16 — 2019-05-07
- 0.0.15 — 2019-04-12
- 0.0.14 — 2019-04-12
- 0.0.13 — 2019-04-11
- 0.0.12 — 2019-04-10
- 0.0.11 — 2019-04-10
- 0.0.10 — 2019-04-05
- 0.0.9 — 2019-04-05
- 0.0.8 — 2019-04-04
- … 8 more at https://npm.io/package/@utilx/stream/versions

## README

# stream-utils

```bash
npm install @typeshell/stream-utils
```

## ReadableX

Provide stream enhance class called ReadnableX, you could enhance your stream.Readable by calling:

```typescript
const enhance_readable_obj = ReadableX.wrap(your_readable_obj)
```

What can you do in ReadableX:

1. hash, encryption
2. zip, gzip, compress and decompress facility
3. easy to convert to string, lines, and other forms easy to process.


## echo: string => stream

echo is the simplest function and display our enhanced Readable, let's see what can we do.

```typescript
const md5_str1 = await echo("hello world").md5()
const md5_str2 = echo("hello world").md5$() // special for echo

// Now you have a zip file, one file called default inside, content is "hello world"
await echo("hello world").zip1ToDisk("a.zip")
```

## dump: stream => dump

Here is the way to convert stream.Readable to string

```typescript
dumps(fs.createReadaStream("input1"))
```

The `dumps()` function is embeded inside our ReadableX

```typescript
cat("input1").dumps()
```


## tee And cat

More powerfule replacement for `fs.createWriteStream()` and `fs.createReadStream()`.
Together it could write code with great simplicity and rich expressiveness

```typescript
cat("input1").tee("out1", "out2", "out3")
// cat input1 | tee out1 out2 out3
```

### tee

tee is a more powerful replacement for `fs.createWriteStream()`

```typescript
fs.createReadStream("input1").pipe(tee(process.stdout, "out1", "out2", "out3"))
```

If you want to append the new content to out2 and out 3, you could using,

```typescript
fs.createReadStream("input1").pipe(tee(process.stdout, "out1", ["out2"], ["out3"]))
```

### cat

cat is a more powerful replacement for `fs.createReadStream()`

```typescript
// Native Readable.pipe could provide one argument
cat("input1", "input2").pipe(process.stdout)

// Recommend using .tee function for multiple outputs
cat("input1", "input2").tee(process.stdout, "out1", ["out2"], ["out3"])
```

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