swc/bundler/tests/.cache/untrusted/4a28c753dfab67a9b4f6e2a2f43251bdbddfcb61.ts

78 lines
99 KiB
TypeScript
Raw Normal View History

// Loaded from https://unpkg.com/@evan/wasm@0.0.50/target/zlib/deno.js
let wasm;
{
const module = new WebAssembly.Module(Uint8Array.from(atob('AGFzbQEAAAABVA1gAn9/AGABfwBgAn9/AX9gA39/fwF/YAV/f39/fwF/YAF/AX9gBX9/f39/AGAEf39/fwBgAX8BfmADf39/AGAAAX9gBn9/f39/fwBgBH9/f38BfwM9PAYHCwwFBAQHBgQGAQIBAAYFAgkKBwMDBAAAAgYEBAMDBwAAAAEJAwUBAQIFAQEFAAIBAgoICAgCAAMAAQQFAXABKCgFAwEAEQYZA38BQYCAwAALfwBB2NfAAAt/AEHY18AACwd1CgZtZW1vcnkCAAR3bGVuADMFd2ZyZWUALwZ3YWxsb2MAJwhjb21wcmVzcwAVDGNvbXByZXNzX3JhdwAWDmRlY29tcHJlc3NfcmF3AB4KZGVjb21wcmVzcwAfCl9fZGF0YV9lbmQDAQtfX2hlYXBfYmFzZQMCCS0BAEEBCyc3Nzc6Nzc3NzA3LjE7NDs4ODU3Nzg4NS04ODg4OTc3LDYpNxwJBgUMAQcK/+oDPPY/ASN/IwBBQGoiByQAAkACQCAEQX8gAiACaiIFIAIgBUsbIgUgBCAFSRsiDkF/SgRAAkACQCAORQRAQQAhBUEBIREMAQsgDiIFECsiEUUNAQsgByAONgIQIAcgETYCCCAHIAU2AgxB6NUAEAQiCwRAIAtBAEHm1QD8CwBBAUEDIANBAXEiHxshIkEBQXwgA0ECcSIFGyEWQYICQYJ4IAUbIRQgA0EJcSEjIAtBuBtqIR0gC0HIGmohJCALQfjPAGohJSALQfg2aiEgIAtB2DRqIRogC0G4GWohISALQZ3SAGohJiALQThqIRkgC0HYG2ohHiABIAJqIQ0CQAJAAkADQAJAAkAgDiAVSQRAQf0BIQYMAQsgAiAcayEbIAstAJhSIQUgByALKAIkNgIoIAcgCykCHDcDICAHIAsoAg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IAUhBkEAC0ECcUUNAQsLIAcgBiADIA1rIBtqIgMgBkEDdiIFIAMgBUkbIgVBA3RrIgY2AhwgAyAFayIDIBtNBEAgByAHKAIYQX8gBnRBf3NxNgIYIAMgJ2ohA0EYIQUgH0UNEyAHQQA2AiRBFyEFDBMLIAMgGxAiAAsgBygCICEIA0AgDiAMayIFRQRAQRMhBUECIRIMFgsgESAOIAwgCGsgDCAHKAIkIgYgBSAFIAZLGyIFEA8gByAGIAVrIgY2AiQgBSAMaiEMQQwhBSAGDQALDBELQR0hBSAHKAIgIgggDEsNEAJAIAcoAiQiBSAMaiIGIA5LDQAgDCAIayAMT0EAQQAgCGsgBUkbDQAgESAOIAwgCCAFEBtBDCEFIAYhDAwRC0ETQQwgBRshBQwQCyAHKAIcIQggBygCKCEKA0AgCCEGA0AgBiAKTwRAIAcgBiAKazYCHCAHIAcoAhgiBSAKQR9xIgZ2NgIYIAcgBygCIEF/IAZ0QX9zIAVxajYCIEEWIQUMEgsgAyANRgR/IBQFIAMtAAAhBSAHIAZBCGoiCDYCHCAHIAcoAhggBSAGdHI2AhggA0EBaiEDIAghBkEACyIFQQJxRQ0ACyAFQf8BcUUNAAsgBUGA/gNxQQh2IQVBECEIDBELAkAgBygCHCIKQQ9PBEAgBygCGCEIDAELIA0gA2tBAU0EQCAHKAIYIQggCiEFA0ACQCAIQf8HcUEBdCAeai4BACIJQX9MBEBBCyEGIAVBC0kNAQNAIAggBkEBa3ZBAXEgCUF/c2oiCkG/BE0EQCAKQQF0IAtqQdgrai4BACIJQX9KBEAgBSEKDAcLIAZBAWoiBiAFTQ0BDAMLCwALIAlBCXZBAWsgBU8NACAFIQoMAwsgAyANRgRAQQ8hCCAWIQUMFAsgAy0AACEGIAcgBUEIaiIKNgIcIAcgBiAFd
const instance = new WebAssembly.Instance(module);
wasm = instance.exports;
}
class mem {
static length() { return wasm.wlen(); }
static alloc(size) { return wasm.walloc(size); }
static free(ptr, size) { return wasm.wfree(ptr, size); }
static u8(ptr, size) { return new Uint8Array(wasm.memory.buffer, ptr, size); }
static u32(ptr, size) { return new Uint32Array(wasm.memory.buffer, ptr, size); }
static copy_and_free(ptr, size) {
let slice = mem.u8(ptr, size).slice();
return (wasm.wfree(ptr, size), slice);
}
}
export function compress(buffer, level = 3) {
const ptr = mem.alloc(buffer.length);
mem.u8(ptr, buffer.length).set(buffer);
return mem.copy_and_free(wasm.compress(ptr, buffer.length, level), mem.length());
}
export function compress_raw(buffer, level = 3) {
const ptr = mem.alloc(buffer.length);
mem.u8(ptr, buffer.length).set(buffer);
return mem.copy_and_free(wasm.compress_raw(ptr, buffer.length, level), mem.length());
}
export function decompress(buffer, limit = 0) {
const ptr = mem.alloc(buffer.length);
mem.u8(ptr, buffer.length).set(buffer);
const x = wasm.decompress(ptr, buffer.length, limit);
if (0 === x) throw new Error('zlib: failed to decompress');
return mem.copy_and_free(x, mem.length());
}
export function decompress_raw(buffer, limit = 0) {
const ptr = mem.alloc(buffer.length);
mem.u8(ptr, buffer.length).set(buffer);
const x = wasm.decompress_raw(ptr, buffer.length, limit);
if (0 === x) throw new Error('zlib: failed to decompress (raw)');
return mem.copy_and_free(x, mem.length());
}
export function decompress_with(buffer, limit = 0, transform) {
const ptr = mem.alloc(buffer.length);
mem.u8(ptr, buffer.length).set(buffer);
const x = wasm.decompress(ptr, buffer.length, limit);
if (0 === x) throw new Error('zlib: failed to decompress');
const u8 = mem.u8(x, mem.length());
const value = transform(u8);
return (mem.free(x, u8.length), value);
}
export function decompress_raw_with(buffer, limit = 0, transform) {
const ptr = mem.alloc(buffer.length);
mem.u8(ptr, buffer.length).set(buffer);
const x = wasm.decompress_raw(ptr, buffer.length, limit);
if (0 === x) throw new Error('zlib: failed to decompress (raw)');
const u8 = mem.u8(x, mem.length());
const value = transform(u8);
return (mem.free(x, u8.length), value);
}