decord/source/12647_Deflate.js

240 lines
6.3 KiB
JavaScript
Raw Normal View History

2026-07-25 08:10:48 +00:00
// Module ID: 12647
// Function ID: 97896
2026-07-20 16:05:17 +00:00
// Name: Deflate
2026-07-25 08:10:48 +00:00
// Dependencies: [12646, 12648, 12649, 12650, 12654]
2026-07-20 16:05:17 +00:00
2026-07-25 08:10:48 +00:00
// Module 12647 (Deflate)
2026-07-23 10:11:24 +00:00
const require = arg1;
const dependencyMap = arg6;
2026-07-20 16:05:17 +00:00
class Deflate {
constructor(arg0) {
self = this;
if (this instanceof Deflate) {
2026-07-23 10:11:24 +00:00
tmp7 = closure_0;
tmp8 = closure_1;
2026-07-20 16:05:17 +00:00
num = 0;
2026-07-23 10:11:24 +00:00
obj = require("_has");
2026-07-20 16:05:17 +00:00
str = "";
obj = arg0;
if (!arg0) {
obj = {};
}
2026-07-23 10:11:24 +00:00
self.options = obj.assign({ level: -1, method: 8, chunkSize: 16384, windowBits: 15, memLevel: 8, strategy: 0, to: "" }, obj);
2026-07-20 16:05:17 +00:00
options = self.options;
if (options.raw) {
if (options.windowBits > 0) {
options.windowBits = -options.windowBits;
}
self.err = 0;
self.msg = "";
flag = false;
self.ended = false;
self.chunks = [];
2026-07-23 10:11:24 +00:00
tmp10 = closure_0;
tmp11 = closure_1;
2026-07-20 16:05:17 +00:00
num4 = 1;
2026-07-23 10:11:24 +00:00
tmp12 = require("ZStream");
2026-07-20 16:05:17 +00:00
prototype2 = tmp12.prototype;
tmp13 = new.target;
tmp14 = new.target;
tmp12 = new tmp12();
tmp16 = tmp12;
self.strm = tmp12;
self.strm.avail_out = 0;
num5 = 2;
2026-07-23 10:11:24 +00:00
obj3 = require("err");
2026-07-20 16:05:17 +00:00
tmp17 = obj3;
deflateInit2Result = obj3.deflateInit2(self.strm, options.level, options.method, options.windowBits, options.memLevel, options.strategy);
if (0 !== deflateInit2Result) {
tmp38 = globalThis;
_Error2 = Error;
2026-07-23 10:11:24 +00:00
tmp39 = closure_0;
tmp40 = closure_1;
2026-07-20 16:05:17 +00:00
num8 = 3;
prototype5 = Error.prototype;
tmp41 = new.target;
tmp42 = new.target;
2026-07-25 08:10:48 +00:00
error = new Error(require("module_12650")[deflateInit2Result]);
2026-07-20 16:05:17 +00:00
tmp44 = error;
throw error;
} else {
if (options.header) {
2026-07-23 10:11:24 +00:00
tmp19 = closure_0;
tmp20 = closure_1;
obj4 = require("err");
2026-07-20 16:05:17 +00:00
deflateSetHeaderResult = obj4.deflateSetHeader(self.strm, options.header);
}
if (options.dictionary) {
str2 = "string";
if ("string" === typeof options.dictionary) {
2026-07-23 10:11:24 +00:00
tmp26 = closure_0;
tmp27 = closure_1;
2026-07-20 16:05:17 +00:00
num6 = 4;
2026-07-23 10:11:24 +00:00
obj5 = require("buf2binstring");
2026-07-20 16:05:17 +00:00
dictionary = obj5.string2buf(options.dictionary);
} else {
tmp22 = toString;
str3 = "[object ArrayBuffer]";
if ("[object ArrayBuffer]" === toString.call(options.dictionary)) {
tmp23 = globalThis;
_Uint8Array = Uint8Array;
prototype3 = Uint8Array.prototype;
tmp24 = new.target;
tmp25 = new.target;
dictionary = new Uint8Array(options.dictionary);
} else {
dictionary = options.dictionary;
}
}
2026-07-23 10:11:24 +00:00
tmp28 = closure_0;
tmp29 = closure_1;
obj6 = require("err");
2026-07-20 16:05:17 +00:00
deflateSetDictionaryResult = obj6.deflateSetDictionary(self.strm, dictionary);
if (0 !== deflateSetDictionaryResult) {
tmp31 = globalThis;
_Error = Error;
2026-07-23 10:11:24 +00:00
tmp32 = closure_0;
tmp33 = closure_1;
2026-07-20 16:05:17 +00:00
num7 = 3;
prototype4 = Error.prototype;
tmp34 = new.target;
tmp35 = new.target;
2026-07-25 08:10:48 +00:00
error1 = new Error(require("module_12650")[deflateSetDictionaryResult]);
2026-07-20 16:05:17 +00:00
tmp37 = error1;
throw error1;
} else {
flag2 = true;
self._dict_set = true;
}
}
return;
}
}
tmp9 = options.gzip && options.windowBits > 0;
if (tmp9) {
num2 = 16;
tmp9 = options.windowBits < 16;
}
if (tmp9) {
num3 = 16;
options.windowBits = options.windowBits + 16;
}
} else {
tmp = Deflate;
prototype = Deflate.prototype;
tmp2 = new.target;
tmp3 = new.target;
tmp4 = arg0;
tmp5 = new Deflate(arg0);
tmp6 = tmp5;
return tmp5;
}
return;
}
push(arg0, arg1) {
strm = this.strm;
if (this.ended) {
flag2 = false;
return false;
} else {
tmp = arg1;
if (arg1 !== ~~arg1) {
flag = true;
num = 0;
if (true === arg1) {
num = 4;
}
tmp = num;
}
str = "string";
if ("string" === typeof arg0) {
2026-07-23 10:11:24 +00:00
tmp9 = closure_0;
tmp10 = closure_1;
2026-07-20 16:05:17 +00:00
num2 = 4;
2026-07-23 10:11:24 +00:00
obj = require("buf2binstring");
2026-07-20 16:05:17 +00:00
strm.input = obj.string2buf(arg0);
num3 = 0;
strm.next_in = 0;
strm.avail_in = strm.input.length;
num4 = 4;
num5 = 2;
tmp11 = 2 !== tmp;
tmp12 = 4 !== tmp;
num6 = 1;
} else {
tmp2 = toString;
str2 = "[object ArrayBuffer]";
if ("[object ArrayBuffer]" !== toString.call(arg0)) {
strm.input = arg0;
}
}
tmp3 = globalThis;
_Uint8Array = Uint8Array;
prototype = Uint8Array.prototype;
tmp4 = new.target;
tmp5 = new.target;
tmp6 = arg0;
uint8Array = new Uint8Array(arg0);
tmp8 = uint8Array;
strm.input = uint8Array;
}
return;
}
onData(arg0) {
chunks = this.chunks;
arr = chunks.push(arg0);
return;
}
onEnd(arg0) {
self = this;
if (0 === arg0) {
str = "string";
if ("string" === self.options.to) {
chunks = self.chunks;
str2 = "";
self.result = chunks.join("");
} else {
2026-07-23 10:11:24 +00:00
tmp = closure_0;
tmp2 = closure_1;
obj = require("_has");
2026-07-20 16:05:17 +00:00
self.result = obj.flattenChunks(self.chunks);
}
}
self.chunks = [];
self.err = arg0;
self.msg = self.strm.msg;
return;
}
}
function deflate(arg0, arg1) {
let arr = new Deflate(arg1);
arr = arr.push(arg0, true);
if (arr.err) {
let msg = arr.msg;
if (!msg) {
2026-07-25 08:10:48 +00:00
msg = require(12650)[arr.err];
2026-07-20 16:05:17 +00:00
}
throw msg;
} else {
return arr.result;
}
}
arg5.Deflate = Deflate;
arg5.deflate = deflate;
arg5.deflateRaw = function deflateRaw(arg0, arg1) {
let obj = arg1;
if (!arg1) {
obj = {};
}
obj.raw = true;
return deflate(arg0, obj);
};
arg5.gzip = function gzip(arg0, arg1) {
let obj = arg1;
if (!arg1) {
obj = {};
}
obj.gzip = true;
return deflate(arg0, obj);
};