[whatwg/streams] What is the expected behaviour of .pipeThrough()? (#765)

According to the specification 

[3.2.4.4. pipeThrough({ writable, readable }, options)](https://streams.spec.whatwg.org/#rs-pipe-through)

> The `pipeThrough` method provides a convenient, chainable way of [piping](https://streams.spec.whatwg.org/#piping) this readable stream through a [transform stream](https://streams.spec.whatwg.org/#transform-stream) (or any other `{ writable, readable }` pair). It simply pipes the stream into the writable side of the supplied pair, and returns the readable side for further use.

Seeking clarification as to what the above paragraph means for practical usage. 

Specifically, the literal text appears to suggest that  the `writable` side of the object would be processed first. 

Perhaps have a general misinterpretation of the intended usage of the `.pipeThrough()` method, here. 

Given 

```
let _chunk;
let [writable, readable] = [
  new WritableStream({
    write(chunk) {
        console.log(chunk);
        _chunk = chunk.map(c => c * 10);
        return _chunk
      },
      close() {
        console.log("done")
      }
  })
, new ReadableStream({
    pull(c, data) {
      console.log(c, _chunk); // `_chunk` is `undefined`
    }
  })
];

let rs = new ReadableStream({
    pull(c) {
      c.enqueue([1, 2, 3]);
      c.close()
    }
  });
  
  rs.pipeThrough({
    writable, readable
  });

```

the expected result initially here was that `writable` would be processed first, though `readable` is processed first.

If the specification is taken literally, how do we access the data transformed at `writable` side at the `readable` side of the pair?

Can we `return` data from a `WritableStream` to a `ReadableStream`?

Can we create a basic example of the practical intended and correct usage of the `pipeThrough` method; both as the current implementation at browsers exist, and, if applicable, how the current implementation at browsers differs from what the specification authors and contributors are ultimately working towards implementing at browsers?



-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/765

Received on Saturday, 19 August 2017 17:09:16 UTC