Re: [streams] Should we "lock" readable streams while piping? (#241)

In IRC @tabatkins made me feel better about implementing .json() in terms of piping to a writable stream that accumulates the data. Roughly his argument was that .json() is a pipe-like consumer, in that it tries to direct all the stream's data to a single place. It hides the piping from you behind a nice simple API, but underneath the covers it's basically piping.

HOWEVER, NEW IDEA:

This might be competely crazy but what if instead of duplicating .read(), .ready, and .state into the ExclusiveStreamReader, we said they were *only* available in the reader, and the stream itself only had pipeTo/pipeThrough (which operate via getting a reader?).

I think the implementation would be more or less the same as https://github.com/whatwg/streams/blob/lock/reference-implementation/lib/experimental/exclusive-stream-reader.js except we'd remove .ready/.read()/.state from ReadableStream.

Whether this is acceptable kind of depends on how strongly we believe that readable streams should primarily be consumed by piping them places. It'd also be a kind of big change, which I am leery of at this stage.

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/241#issuecomment-64477629

Received on Tuesday, 25 November 2014 21:53:54 UTC