This old typeof check made me questions what's going on here, I think we can make simpler by doing something like:
```
      var bufferLength = this.bufferLength;
      blockLen = Math.min(blockLen, bytes.length - bytesPos);
      var buffer = this.ensureBuffer(bufferLength + blockLen);
      var end = bufferLength + blockLen;
      this.bufferLength = end;
      for (var n = bufferLength; n < end; ++n) {
        buffer[n] = bytes[bytesPos++];
      }
      if (bytesPos >= bytes.length) {
        this.eof = true;
      }
      this.bytesPos = bytesPos;
```