title: How do you read a file or Stream synchronously in node.js?
body: <p>Please, no lectures about how I should be doing everything asynchronously.  Sometimes I want to do things the easy obvious way, so I can move on to other work.  </p>
  
  <p>For some reason, the following code doesn't work.  It matches code I found on a <a href="https://stackoverflow.com/questions/18158806/node-js-readable-file-stream-not-getting-data">recent SO question</a>.  Did node change or break something?</p>
  
  <pre><code>var fs = require('fs');
  var rs = fs.createReadStream('myfilename');  // for example
                                               // but I might also want to read from
                                               // stdio, an HTTP request, etc...
  var buffer = rs.read();     // simple for SCCCE example, normally you'd repeat in a loop...
  console.log(buffer.toString());
  </code></pre>
  
  <p>After the read, the buffer is null.</p>
  
  <p>Looking at rs in the debugger, I see</p>
  
  <pre><code>events  
     has end and open functions, nothing else
  _readableState
    buffer = Array[0]
    emittedReadable = false
    flowing = false   &lt;&lt;&lt; this appears to be correct
    lots of other false/nulls/undefined
  fd = null   &lt;&lt;&lt; suspicious???
  readable = true
    lots of other false/nulls/undefined
  </code></pre>