brianloveswords / zlib-browserify

browserifyable zlib implementation for JavaScript
MIT License
31 stars 11 forks source link

this code fails in the browser but works in node #6

Open andrewrk opened 11 years ago

andrewrk commented 11 years ago
var text = "H4sIAAAAAAAAA+3czU7CUBSF0TIA48DEgQ58/xdVIiQE7ukPXHoOsFbyjTRQaHcUJA4DAAAAAAAAAAAAAAAAAABc2h4CLtkHxOwDYvYBMfuAmH1AzD4gZh8Qsw+I2QfE7ANi9gEx+4CYfUDMPiBmHxCzD4jZB8TsA2L2ATH7gJh9QMw+IGYfELMPiNkHxOwDYvYBMfuAmH3w6j5POmcfVPSz0v3sN/Fx0vlG7IMKNn+9jXSLsdudyj7Itt/GdqJbfDeaur+e9w/XmrONe1yfX8OyzZDj+HvFe/aBJJi7jbWuz7HN0N/U787n10fVjcx9rbzkNfWSbWRen8fNPJtbXpP16nhup76+nfG9c16nZj/ea56b6vt4Vkuf/0fpFR+zffSXfT7twz4qyz6f92o3Uvax2cfjyD6fso/Kss+n+jb2c3M39LHpdDunrvmczBqfrck+n+rbWu+ptWS/11fh/UNpX0v2MUlVask+JqlKLdnHJFWpJfuYpCq1ZB+TVKVX+7urJEmSJEmSVLHW/3SR9B8AAAAAAAAAAAAAAAAAAAAAAAAANfwCLfpEO4A4AQA=";
var zipped = new Buffer(text, 'base64');
var zlib = require('zlib');
zlib.gunzip(zipped, function(err, buf) {
  if (err) {
    throw err;
  } else {
    console.log(buf.length);
  }
});

Compile that with browserify and the console says "invalid file signature: "

I wrote a test for zlib-browserify and it passed. So it must be something that breaks in the browser but works in node. Is there a way to get a debug build so that we can troubleshoot the issue?

andrewrk commented 11 years ago

Interesting fact: if I use a bops instance instead of a Buffer, it works.