title: Pipe the stream between stdin and stdout
body: <p>We can echo line by line on <em>nodejs</em> via <a href="https://nodejs.org/api/stream.html#stream_readable_pipe_destination_options" rel="nofollow noreferrer">stream pipe</a> from <em>stdin</em> to <em>stdout</em>, i.e. from <em>Readable</em> to <em>Writable</em> stream:</p>
  
  <pre><code>process.stdin.pipe(process.stdout);
  </code></pre>
  
  <p>Confusingly, it also works same as before from <em>stdout</em> to <em>stdin</em>, i.e. from <em>Writable</em> to <em>Readable</em> stream below. Why?</p>
  
  <pre><code>process.stdout.pipe(process.stdin);
  </code></pre>
  
  <p><strong>@EDIT</strong></p>
  
  <p>The similar test with <a href="https://golang.org/pkg/io/#Copy" rel="nofollow noreferrer">io.Copy</a> in <em>golang</em> has reproduced the aforementioned issue. The cross-validation seems to hint the builtin <em>pipe</em> implementation can't be wrong on both incumbent platforms.</p>
  
  <pre><code> package main                                                                                                          
  
   import (                                                                                                              
       "io"                                                                                                              
       "os"                                                                                                              
   )                                                                                                                     
  
   func main() {                                                                                                         
       io.Copy(os.Stdout, os.Stdin)                                                                                      
       // io.Copy(os.Stdin, os.Stdout) /* Also works than expected. */                                                                
   }                                                                                                                     
  </code></pre>
  
  <p><strong>@EDIT 2</strong></p>
  
  <p>For further investigation another test with <a href="https://doc.deno.land/https/github.com/denoland/deno/releases/latest/download/lib.deno.d.ts#Deno.copy" rel="nofollow noreferrer">Deno.copy</a> on the third platform <em>deno</em> behaves as expected:</p>
  
  <pre><code>Deno.copy(Deno.stdout, Deno.stdin); /* Works as expected. */
  // Deno.copy(Deno.stdin, Deno.stdout); /* Fails as expected. */
  </code></pre>