UNPKG

debrotli

Version:

Blazing fast brotli decompressor powered by WebAssembly.

61 lines (53 loc) 1.66 kB
// @generated file from wasmbuild -- do not edit // @ts-nocheck: generated // deno-lint-ignore-file // deno-fmt-ignore-file let wasm; export function __wbg_set_wasm(val) { wasm = val; } let cachedUint8ArrayMemory0 = null; function getUint8ArrayMemory0() { if ( cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0 ) { cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); } return cachedUint8ArrayMemory0; } let WASM_VECTOR_LEN = 0; function passArray8ToWasm0(arg, malloc) { const ptr = malloc(arg.length * 1, 1) >>> 0; getUint8ArrayMemory0().set(arg, ptr / 1); WASM_VECTOR_LEN = arg.length; return ptr; } function getArrayU8FromWasm0(ptr, len) { ptr = ptr >>> 0; return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); } /** * Decompresses a Brotli-compressed buffer, returning the decompressed data. * * If the data cannot be decompressed, a copy of the input is returned. * * @param {Uint8Array} data - The Brotli-compressed data to decompress. * @returns {Uint8Array} - The decompressed data. */ export function decompress(data) { const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_malloc); const len0 = WASM_VECTOR_LEN; const ret = wasm.decompress(ptr0, len0); var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice(); wasm.__wbindgen_free(ret[0], ret[1] * 1, 1); return v2; } export function __wbindgen_init_externref_table() { const table = wasm.__wbindgen_export_0; const offset = table.grow(4); table.set(0, undefined); table.set(offset + 0, undefined); table.set(offset + 1, null); table.set(offset + 2, true); table.set(offset + 3, false); }