182 lines
5.1 KiB
JavaScript
182 lines
5.1 KiB
JavaScript
// Metro module 4802 (f4803).
|
|
import DataView2 from "./DataView";
|
|
function $mk75011() {
|
|
return (a0) => String.fromCharCode(a0);
|
|
}
|
|
export function getDataView(a0, a1, a2) {
|
|
let dataView;
|
|
try {
|
|
dataView = new DataView(a0, a1, a2);
|
|
} catch ($e) {
|
|
return new DataView2(a0, a1, a2);
|
|
}
|
|
return dataView;
|
|
}
|
|
export function getStringFromDataView(a0, a1, a2) {
|
|
let r16, byteLength;
|
|
const r6 = [];
|
|
if (0 < a2) {
|
|
const r3 = a1 + 0 < a0.byteLength;
|
|
let r11 = 0;
|
|
if (r3) {
|
|
do {
|
|
r6.push(a0.getUint8(a1 + r11));
|
|
const r1 = r11 + 1;
|
|
if (!(r1 < a2)) {
|
|
break;
|
|
}
|
|
r16 = a1 + r1;
|
|
byteLength = a0.byteLength;
|
|
r11 = r1;
|
|
} while (r16 < byteLength);
|
|
}
|
|
}
|
|
return r6.map($mk75011()).join("");
|
|
}
|
|
export function getNullTerminatedStringFromDataView(a0, a1) {
|
|
let r16, byteLength;
|
|
const r7 = [];
|
|
const r4 = a1 + 0 < a0.byteLength;
|
|
let r0 = 0;
|
|
if (r4) {
|
|
do {
|
|
const uint8 = a0.getUint8(a1 + r0);
|
|
const r1 = r0;
|
|
if (uint8 === 0) {
|
|
break;
|
|
}
|
|
r7.push(uint8);
|
|
const r15 = r1 + 1;
|
|
r16 = a1 + r15;
|
|
byteLength = a0.byteLength;
|
|
r0 = r15;
|
|
} while (r16 < byteLength);
|
|
}
|
|
return r7.map($mk75011()).join("");
|
|
}
|
|
export function getUnicodeStringFromDataView(a0, a1, a2) {
|
|
let r16, byteLength;
|
|
const r7 = [];
|
|
if (0 < a2) {
|
|
const r4 = a1 + 0 < a0.byteLength;
|
|
let r0 = 0;
|
|
if (r4) {
|
|
do {
|
|
r7.push(a0.getUint16(a1 + r0));
|
|
const r1 = r0 + 2;
|
|
if (!(r1 < a2)) {
|
|
break;
|
|
}
|
|
r16 = a1 + r1;
|
|
byteLength = a0.byteLength;
|
|
r0 = r1;
|
|
} while (r16 < byteLength);
|
|
}
|
|
}
|
|
if (r7[r7.length - 1] === 0) {
|
|
r7.pop();
|
|
}
|
|
return r7.map($mk75011()).join("");
|
|
}
|
|
export function getPascalStringFromDataView(a0, a1) {
|
|
let r20, byteLength;
|
|
const uint8 = a0.getUint8(a1);
|
|
const r12 = [uint8, ,];
|
|
const r8 = a1 + 1;
|
|
const r7 = [];
|
|
if (0 < uint8) {
|
|
const r3 = r8 + 0 < a0.byteLength;
|
|
let r14 = 0;
|
|
if (r3) {
|
|
do {
|
|
r7.push(a0.getUint8(r8 + r14));
|
|
const r1 = r14 + 1;
|
|
if (!(r1 < uint8)) {
|
|
break;
|
|
}
|
|
byteLength = a0.byteLength;
|
|
r20 = r8 + r1;
|
|
r14 = r1;
|
|
} while (r20 < byteLength);
|
|
}
|
|
}
|
|
r12[1] = r7.map($mk75011()).join("");
|
|
return r12;
|
|
}
|
|
export function getStringValueFromArray(a0) {
|
|
return a0.map($mk75011()).join("");
|
|
}
|
|
export function getCharacterArray(a0) {
|
|
return a0.split("").map((item) => item.charCodeAt(0));
|
|
}
|
|
export function objectAssign() {
|
|
const r6 = 1 < arguments.length;
|
|
let r2 = 1;
|
|
if (r6) {
|
|
do {
|
|
const r9 = arguments[r2];
|
|
const r0 = r2;
|
|
for (const key in r9) {
|
|
arguments[0][key] = arguments[r0][key];
|
|
}
|
|
r2 = r0 + 1;
|
|
} while (r2 < arguments.length);
|
|
}
|
|
return arguments[0];
|
|
}
|
|
export function deferInit(a0, a1, c14443_2) {
|
|
let c14443_3 = false;
|
|
Object.defineProperty(a0, a1, {
|
|
get: () => {
|
|
if (!c14443_3) {
|
|
c14443_3 = true;
|
|
const r6 = Object;
|
|
r6.defineProperty(a0, a1, {
|
|
configurable: true,
|
|
enumerable: true,
|
|
value: c14443_2.apply(a0),
|
|
writable: true
|
|
});
|
|
}
|
|
return a0[a1];
|
|
},
|
|
configurable: true,
|
|
enumerable: true
|
|
});
|
|
}
|
|
export function getBase64Image(a0) {
|
|
return typeof globalThis.btoa !== "undefined" ? typeof a0 === "string" ? btoa(a0) : btoa(Array.prototype.reduce.call(new Uint8Array(a0), (a0, a1) => a0 + String.fromCharCode(a1), "")) : typeof globalThis.Buffer !== "undefined" ? Buffer.from !== void 0 ? Buffer.from(a0).toString("base64") : new Buffer(a0).toString("base64") : void 0;
|
|
}
|
|
export function dataUriToBuffer(a0) {
|
|
const r13 = a0.substring(a0.indexOf(",") + 1);
|
|
if (a0.indexOf(";base64") !== -1) {
|
|
if (typeof globalThis.atob !== "undefined") {
|
|
return Uint8Array.from(atob(r13), (a0) => a0.charCodeAt(0)).buffer;
|
|
}
|
|
if (typeof globalThis.Buffer === "undefined") {
|
|
return void 0;
|
|
}
|
|
return Buffer.from !== void 0 ? Buffer.from(r13, "base64") : new Buffer(r13, "base64");
|
|
}
|
|
const r7 = decodeURIComponent(r13);
|
|
return typeof globalThis.Buffer !== "undefined" ? Buffer.from !== void 0 ? Buffer.from(r7) : new Buffer(r7) : Uint8Array.from(r7, (a0) => a0.charCodeAt(0)).buffer;
|
|
}
|
|
export function padStart(a0, a1, a2) {
|
|
return new Array(a1 - a0.length + 1).join(a2) + a0;
|
|
}
|
|
export function parseFloatRadix(a0, a1) {
|
|
return parseInt(a0.replace(".", ""), a1) / Math.pow(a1, (a0.split(".")[1] || "").length);
|
|
}
|
|
export function strRepeat(a0, a1) {
|
|
return new Array(a1 + 1).join(a0);
|
|
}
|
|
export const COMPRESSION_METHOD_DEFLATE = 0;
|
|
export function decompress(a0, a1, c14444_0, r6 = "string") {
|
|
if (a1 === 0 && typeof globalThis.DecompressionStream === "function") {
|
|
const decompressionStream = new DecompressionStream("deflate");
|
|
const r35 = new Blob([a0]).stream().pipeThrough(decompressionStream);
|
|
return r6 === "dataview" ? new Response(r35).arrayBuffer().then((result) => new DataView(result)) : new Response(r35).arrayBuffer().then((result) => new TextDecoder(c14444_0).decode(result));
|
|
}
|
|
return a1 !== void 0 ? Promise.reject(`Unknown compression method ${a1}.`) : a0;
|
|
}
|