@utilx/stream
```bash npm install @typeshell/stream-utils ```
Last updated a year ago by lteam .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @utilx/stream 
SYNC missed versions from official npm registry.

stream-utils

npm install @typeshell/stream-utils

ReadableX

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

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.

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

dumps(fs.createReadaStream("input1"))

The dumps() function is embeded inside our ReadableX

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

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

tee

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

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,

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

cat

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

// 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"])

Current Tags

  • 0.0.22                                ...           latest (a year ago)

23 Versions

  • 0.0.22                                ...           a year ago
  • 0.0.21                                ...           a year ago
  • 0.0.20                                ...           a year ago
  • 0.0.19                                ...           a year ago
  • 0.0.18                                ...           a year ago
  • 0.0.17                                ...           a year ago
  • 0.0.16                                ...           a year ago
  • 0.0.15                                ...           a year ago
  • 0.0.14                                ...           a year ago
  • 0.0.13                                ...           a year ago
  • 0.0.12                                ...           a year ago
  • 0.0.11                                ...           a year ago
  • 0.0.10                                ...           a year ago
  • 0.0.9                                ...           a year ago
  • 0.0.8                                ...           a year ago
  • 0.0.7                                ...           a year ago
  • 0.0.6                                ...           a year ago
  • 0.0.5                                ...           a year ago
  • 0.0.4                                ...           a year ago
  • 0.0.3                                ...           a year ago
  • 0.0.2                                ...           a year ago
  • 0.0.1                                ...           a year ago
  • 0.0.0                                ...           a year ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 24
Last Day 0
Last Week 0
Last Month 0
Dependencies (10)
Dev Dependencies (10)

Copyright 2014 - 2016 © taobao.org |