{"action":"created","issue":{"url":"https://api.github.com/repos/whatwg/streams/issues/765","repository_url":"https://api.github.com/repos/whatwg/streams","labels_url":"https://api.github.com/repos/whatwg/streams/issues/765/labels{/name}","comments_url":"https://api.github.com/repos/whatwg/streams/issues/765/comments","events_url":"https://api.github.com/repos/whatwg/streams/issues/765/events","html_url":"https://github.com/whatwg/streams/issues/765","id":251437665,"number":765,"title":"What is the expected behaviour of .pipeThrough()?","user":{"login":"guest271314","id":4174848,"avatar_url":"https://avatars0.githubusercontent.com/u/4174848?v=4","gravatar_id":"","url":"https://api.github.com/users/guest271314","html_url":"https://github.com/guest271314","followers_url":"https://api.github.com/users/guest271314/followers","following_url":"https://api.github.com/users/guest271314/following{/other_user}","gists_url":"https://api.github.com/users/guest271314/gists{/gist_id}","starred_url":"https://api.github.com/users/guest271314/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guest271314/subscriptions","organizations_url":"https://api.github.com/users/guest271314/orgs","repos_url":"https://api.github.com/users/guest271314/repos","events_url":"https://api.github.com/users/guest271314/events{/privacy}","received_events_url":"https://api.github.com/users/guest271314/received_events","type":"User","site_admin":false},"labels":[{"id":66378360,"url":"https://api.github.com/repos/whatwg/streams/labels/question","name":"question","color":"c7def8","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":14,"created_at":"2017-08-19T17:08:50Z","updated_at":"2017-08-21T16:34:35Z","closed_at":null,"body":"According to the specification \r\n\r\n[3.2.4.4. pipeThrough({ writable, readable }, options)](https://streams.spec.whatwg.org/#rs-pipe-through)\r\n\r\n> 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.\r\n\r\nSeeking clarification as to what the above paragraph means for practical usage. \r\n\r\nSpecifically, the literal text appears to suggest that  the `writable` side of the object would be processed first. \r\n\r\nPerhaps have a general misinterpretation of the intended usage of the `.pipeThrough()` method, here. \r\n\r\nGiven \r\n\r\n```\r\nlet _chunk;\r\nlet [writable, readable] = [\r\n  new WritableStream({\r\n    write(chunk) {\r\n        console.log(chunk);\r\n        _chunk = chunk.map(c => c * 10);\r\n        return _chunk\r\n      },\r\n      close() {\r\n        console.log(\"done\")\r\n      }\r\n  })\r\n, new ReadableStream({\r\n    pull(c, data) {\r\n      console.log(c, _chunk); // `_chunk` is `undefined`\r\n    }\r\n  })\r\n];\r\n\r\nlet rs = new ReadableStream({\r\n    pull(c) {\r\n      c.enqueue([1, 2, 3]);\r\n      c.close()\r\n    }\r\n  });\r\n  \r\n  rs.pipeThrough({\r\n    writable, readable\r\n  });\r\n\r\n```\r\n\r\nthe expected result initially here was that `writable` would be processed first, though `readable` is processed first.\r\n\r\nIf the specification is taken literally, how do we access the data transformed at `writable` side at the `readable` side of the pair?\r\n\r\nCan we `return` data from a `WritableStream` to a `ReadableStream`?\r\n\r\nCan 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?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/whatwg/streams/issues/comments/323793185","html_url":"https://github.com/whatwg/streams/issues/765#issuecomment-323793185","issue_url":"https://api.github.com/repos/whatwg/streams/issues/765","id":323793185,"user":{"login":"guest271314","id":4174848,"avatar_url":"https://avatars0.githubusercontent.com/u/4174848?v=4","gravatar_id":"","url":"https://api.github.com/users/guest271314","html_url":"https://github.com/guest271314","followers_url":"https://api.github.com/users/guest271314/followers","following_url":"https://api.github.com/users/guest271314/following{/other_user}","gists_url":"https://api.github.com/users/guest271314/gists{/gist_id}","starred_url":"https://api.github.com/users/guest271314/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/guest271314/subscriptions","organizations_url":"https://api.github.com/users/guest271314/orgs","repos_url":"https://api.github.com/users/guest271314/repos","events_url":"https://api.github.com/users/guest271314/events{/privacy}","received_events_url":"https://api.github.com/users/guest271314/received_events","type":"User","site_admin":false},"created_at":"2017-08-21T16:34:35Z","updated_at":"2017-08-21T16:34:35Z","body":"@ricea  Was able to achieve requirement using `.pipeTo()` with a variation of @domenic code at http://jsbin.com/hicawawizo/edit?html,console, and by compiling the files at https://github.com/whatwg/streams/blob/master/reference-implementation/lib/ into a single file and using `.pipeThrough()`, with the adjustment of using `.enqueue()` instead of `return` within `transform` function.\r\n"}}
{"actor":{"display_login":"guest271314"}}