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

@domenic A variation of  your code from jsbin which logs the order `writable` closed -> `readable` closed

```
function pipeThrough(data) {
  "use strict";
  console.clear();

  let readable;

  let writable = new WritableStream({
    write(chunk) {
        readable = new ReadableStream({
          pull(c) {
            c.enqueue(chunk);
            c.close();
          }
        })
      },
      close(c) {
        console.log("done")
      }
  });

  let writer = writable.getWriter();
  writer.write(data);
  writer.close();
  return writer.closed.then(() => {
    console.log("really done");
    return readable
  });

}

pipeThrough([1, 2, 3])
  .then(reader => {
    let stream = reader.getReader();
    let fn = ({value,done}) => {
      if (done) return stream.closed.then(() => ({done}));
      console.log(value, done);
      return stream.read().then(fn)
    }
    return stream.read().then(fn)
  })
  .then(done => console.log(done));
```

-- 
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#issuecomment-323557537

Received on Sunday, 20 August 2017 01:33:48 UTC