ukyo / zlib-asm

Other
23 stars 6 forks source link

Zero-length data causes zlib.rawInflate() error #1

Closed duanyao closed 9 years ago

duanyao commented 9 years ago

I use zlib.rawDeflate() to compress a zero-length data, then use zlib.rawInflate() to decompress it, however the latter throws an TypeError. Test code:

  it('should decompress the raw deflated zero-length data correctly.', function () {
    var data = new Uint8Array(0);
    var def = zlib.rawDeflate(data);
    var inf = zlib.rawInflate(def); // throws "TypeError: Reduce of empty array with no initial value"
    expect(inf.length).to.equal(0);
  });