{"action":"created","issue":{"url":"https://api.github.com/repos/yutakahirano/fetch-with-streams/issues/30","labels_url":"https://api.github.com/repos/yutakahirano/fetch-with-streams/issues/30/labels{/name}","comments_url":"https://api.github.com/repos/yutakahirano/fetch-with-streams/issues/30/comments","events_url":"https://api.github.com/repos/yutakahirano/fetch-with-streams/issues/30/events","html_url":"https://github.com/yutakahirano/fetch-with-streams/issues/30","id":66510936,"number":30,"title":"Uploading: write to a writable stream, or pass in a readable stream?","user":{"login":"domenic","id":617481,"avatar_url":"https://avatars.githubusercontent.com/u/617481?v=3","gravatar_id":"","url":"https://api.github.com/users/domenic","html_url":"https://github.com/domenic","followers_url":"https://api.github.com/users/domenic/followers","following_url":"https://api.github.com/users/domenic/following{/other_user}","gists_url":"https://api.github.com/users/domenic/gists{/gist_id}","starred_url":"https://api.github.com/users/domenic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domenic/subscriptions","organizations_url":"https://api.github.com/users/domenic/orgs","repos_url":"https://api.github.com/users/domenic/repos","events_url":"https://api.github.com/users/domenic/events{/privacy}","received_events_url":"https://api.github.com/users/domenic/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yutakahirano/fetch-with-streams/labels/not%20included%20in%20the%20first%20release","name":"not included in the first release","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":75,"created_at":"2015-04-06T02:43:52Z","updated_at":"2015-04-13T23:48:44Z","closed_at":null,"body":"Previously: https://github.com/yutakahirano/fetch-with-streams/pull/3 and https://github.com/yutakahirano/fetch-with-streams/issues/25#issuecomment-89826020\r\n\r\nMy opinion is that writing to a response body, i.e. doing an upload or writes to a cache, should be represented by a writable stream. It feels like a major failure of the entire writable stream design if we can't use it for cases like this.\r\n\r\nIt's true that in general you never \"need\" writable streams, as you can always have functions that accept readable streams and then directly feed their contents to underlying resources (e.g. directly call write(2) on the cache or send(2) on the socket). But kind of the entire point is to have an abstraction that lets you hide away that complexity.\r\n\r\n@wanderview is not so sure...\r\n\r\nIt's also worth noting there is an equivalence here:\r\n\r\n- Given `function f(bodyWriter) { bodyWriter(ws); }`, we can get `g(rs)` via\r\n   ```js\r\n   function g(rs) {\r\n     f(ws => rs.pipeTo(ws));\r\n   }\r\n   ```\r\n\r\n- Given `function g(rs) { doSomethingWith(rs); }`, we can get `f(bodyWriter)` via\r\n  ```js\r\n  function f(bodyWriter) {\r\n    const ts = new TransformStream(/* identity transform */);\r\n    bodyWriter(ts.writable);\r\n    g(ts.readable);\r\n  }\r\n  ```\r\n\r\nBut I am more interested in what is natural to implementations. My hope would be that you could supply a writable stream that would directly wrap to the socket for upload, or file descriptor for write to cache, and not have to do any adaptation of the type shown in the second example."},"comment":{"url":"https://api.github.com/repos/yutakahirano/fetch-with-streams/issues/comments/92538554","html_url":"https://github.com/yutakahirano/fetch-with-streams/issues/30#issuecomment-92538554","issue_url":"https://api.github.com/repos/yutakahirano/fetch-with-streams/issues/30","id":92538554,"user":{"login":"domenic","id":617481,"avatar_url":"https://avatars.githubusercontent.com/u/617481?v=3","gravatar_id":"","url":"https://api.github.com/users/domenic","html_url":"https://github.com/domenic","followers_url":"https://api.github.com/users/domenic/followers","following_url":"https://api.github.com/users/domenic/following{/other_user}","gists_url":"https://api.github.com/users/domenic/gists{/gist_id}","starred_url":"https://api.github.com/users/domenic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/domenic/subscriptions","organizations_url":"https://api.github.com/users/domenic/orgs","repos_url":"https://api.github.com/users/domenic/repos","events_url":"https://api.github.com/users/domenic/events{/privacy}","received_events_url":"https://api.github.com/users/domenic/received_events","type":"User","site_admin":false},"created_at":"2015-04-13T23:48:43Z","updated_at":"2015-04-13T23:48:43Z","body":"Oh I see, you were probably thinking of your proposal inhttps://github.com/yutakahirano/fetch-with-streams/issues/30#issuecomment-90985633 ? That would indeed take care of my concern."}}