Commit Graph

5 Commits

Author SHA1 Message Date
Guangcong Luo
9fe45238f5
Introduce chunk readers for ReadStream (#7215)
This adds new functions `stream.byChunk(bytes)`, `stream.byLine()` etc
which parse a `ReadStream` into an `ObjectReadStream<string>` which
can then be consumed with for-await.

Fixes #7195
2020-09-27 08:55:59 -07:00
Guangcong Luo
1e5b5ab465 Update Streams API with pushEnd/writeEnd
Previously, ending a read stream was `stream.push(null)`, and ending a
write stream was `stream.end()`. This was often confusing, and so now,
these are consistently `stream.pushEnd()` and `stream.writeEnd()`.

This refactor already found a bug in which `stream.end()` was used
where `stream.push(null)` should have been.

Also in this refactor: By default, `pushError` ends the stream. You can
pass `true` as the second parameter if the error is recoverable (the
stream shouldn't end).
2020-06-10 16:07:24 -07:00
Guangcong Luo
efa0af0ef1 Propagate errors through streams 2019-03-17 07:48:02 +09:00
Guangcong Luo
1c119bf3fa Fix streams.js doc comment
(Also improve STREAMS documentation a bit)
2018-01-20 12:16:47 -06:00
Guangcong Luo
4969fb0790 Add Streams library
I've finally been sufficiently frustrated by Node's Streams API to
straight-up write my own.

This is what a Streams API looks like when you don't try to pretend
Promises don't exist. So much easier to use.
2018-01-12 22:19:05 -06:00