title: ReadStream: Internal buffer does not fill up anymore
body: <p>I have a fs.ReadStream object that points to a pretty big file. Now I would like to read 8000 bytes from the ReadStream, but the internal buffer is only 6000 bytes. So my approach would be to read those 6000 bytes and wait for the internal buffer to fill up again by using a while-loop that checks whether the internal buffer length is not 0 anymore.</p>
  
  <p>Something like this:</p>
  
  <pre><code>BinaryObject.prototype.read = function(length) {
    var value;
  
    // Check whether we have enough data in the internal buffer
    if (this.stream._readableState.length &lt; length) {
      // Not enough data - read the full internal buffer to
      // force the ReadStream to fill it again.
      value = this.read(this.stream._readableState.length);
      while (this.stream._readableState.length === 0) {
        // Wait...?
      }
      // We should have some more data in the internal buffer
      // here... Read the rest and add it to our `value` buffer
      // ... something like this:
      //
      // value.push(this.stream.read(length - value.length))
      // return value
    } else {
      value = this.stream.read(length);
      this.stream.position += length;
      return value;
    }
  };
  </code></pre>
  
  <p>The problem is, that the buffer is not filled anymore - the script will just idle in the while loop.</p>
  
  <p>What is the best approach to do this?</p>