lib/utils/stream-buf.js
function(size) {
    var buffers;
    // read min(buffer, size || infinity)
    if (size) {
      buffers = [];
      while (size && this.buffers.length && !this.buffers[0].eod) {
        var first = this.buffers[0];
        var buffer = first.read(size);
        size -= buffer.length;
        buffers.push(buffer);
        if (first.eod && first.full) {
          this.buffers.shift();
        }
      }
      return Buffer.concat(buffers);
    }

    buffers = this.buffers.map(buf => buf.toBuffer())
      .filter(Boolean);
    this.buffers = [];
    return Buffer.concat(buffers);
  }
function(size) {
    var buffers;
    // read min(buffer, size || infinity)
    if (size) {
      buffers = [];
      while (size && this.buffers.length && !this.buffers[0].eod) {
        var first = this.buffers[0];
        var buffer = first.read(size);
        size -= buffer.length;
        buffers.push(buffer);
        if (first.eod && first.full) {
          this.buffers.shift();
        }
      }
      return Buffer.concat(buffers);
    }

    buffers = this.buffers.map(buf => buf.toBuffer())
      .filter(Boolean);
    this.buffers = [];
    return Buffer.concat(buffers);
  }
function ( size ) { var buffers ; // read min(buffer, size || infinity) if ( size ) { buffers = [ ] ; while ( size && this . buffers . length && ! this . buffers [ 0 ] . eod ) { var first = this . buffers [ 0 ] ; var buffer = first . read ( size ) ; size -= buffer . length ; buffers . push ( buffer ) ; if ( first . eod && first . full ) { this . buffers . shift ( ) ; } } return Buffer . concat ( buffers ) ; } buffers = this . buffers . map ( buf => buf . toBuffer ( ) ) . filter ( Boolean ) ; this . buffers = [ ] ; return Buffer . concat ( buffers ) ; }
readable event readable - some data is now available event data - switch to flowing mode - feeds chunks to handler event end - no more data event close - optional, indicates upstream close event error - duh
readable event readable - some data is now available event data - switch to flowing mode - feeds chunks to handler event end - no more data event close - optional indicates upstream close event error - duh