inflator.partial.js 819 B

1234567891011121314151617181920212223242526272829303132
  1. var zlib = require('./lib/zlib/inflate.js');
  2. var ZStream = require('./lib/zlib/zstream.js');
  3. var Inflate = function () {
  4. this.strm = new ZStream();
  5. this.chunkSize = 1024 * 10 * 10;
  6. this.strm.output = new Uint8Array(this.chunkSize);
  7. this.windowBits = 5;
  8. zlib.inflateInit(this.strm, this.windowBits);
  9. };
  10. Inflate.prototype = {
  11. inflate: function (data, flush) {
  12. this.strm.input = data;
  13. this.strm.avail_in = this.strm.input.length;
  14. this.strm.next_in = 0;
  15. this.strm.next_out = 0;
  16. this.strm.avail_out = this.chunkSize;
  17. zlib.inflate(this.strm, flush);
  18. return new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
  19. },
  20. reset: function () {
  21. zlib.inflateReset(this.strm);
  22. }
  23. };
  24. module.exports = {Inflate: Inflate};