0.0.8 • Published 5 years ago

@typeshell/stream-utils v0.0.8

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

stream-utils

npm install @typeshell/stream-utils

Provide stream enhance function

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

with string

toString

Here is the way to convert stream.Readable to string

toString(fs.createReadaStream("input1"))

If you are using cat

cat("input1").toString()

fromString

If you want to convert string to stream,

fromString("hello world")
0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago