cione-comp-lib
Version:
`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`
88 lines (87 loc) • 2.95 kB
JavaScript
import { __exports as inflator } from "../../../../_virtual/inflator.mjs";
import "./vendor/pako/lib/zlib/inflate.mjs";
import "./vendor/pako/lib/zlib/zstream.mjs";
import { __exports as zstream } from "../../../../_virtual/zstream.mjs";
import { __exports as inflate } from "../../../../_virtual/inflate.mjs";
(function(exports) {
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _inflate2 = inflate;
var _zstream = _interopRequireDefault(zstream);
function _interopRequireDefault(obj) {
return obj && obj.__esModule ? obj : { "default": obj };
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor)
descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps)
_defineProperties(Constructor.prototype, protoProps);
if (staticProps)
_defineProperties(Constructor, staticProps);
return Constructor;
}
var Inflate = /* @__PURE__ */ function() {
function Inflate2() {
_classCallCheck(this, Inflate2);
this.strm = new _zstream["default"]();
this.chunkSize = 1024 * 10 * 10;
this.strm.output = new Uint8Array(this.chunkSize);
this.windowBits = 5;
(0, _inflate2.inflateInit)(this.strm, this.windowBits);
}
_createClass(Inflate2, [{
key: "setInput",
value: function setInput(data) {
if (!data) {
this.strm.input = null;
this.strm.avail_in = 0;
this.strm.next_in = 0;
} else {
this.strm.input = data;
this.strm.avail_in = this.strm.input.length;
this.strm.next_in = 0;
}
}
}, {
key: "inflate",
value: function inflate2(expected) {
if (expected > this.chunkSize) {
this.chunkSize = expected;
this.strm.output = new Uint8Array(this.chunkSize);
}
this.strm.next_out = 0;
this.strm.avail_out = expected;
var ret = (0, _inflate2.inflate)(this.strm, 0);
if (ret < 0) {
throw new Error("zlib inflate failed");
}
if (this.strm.next_out != expected) {
throw new Error("Incomplete zlib block");
}
return new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
}
}, {
key: "reset",
value: function reset() {
(0, _inflate2.inflateReset)(this.strm);
}
}]);
return Inflate2;
}();
exports["default"] = Inflate;
})(inflator);