@auser/wasm-flate
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -7,3 +7,3 @@ { | ||
], | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"files": [ | ||
@@ -10,0 +10,0 @@ "wasm_flate_bg.wasm", |
@@ -5,5 +5,5 @@ /* tslint:disable */ | ||
* @param {string} base_compressed | ||
* @returns {any} | ||
* @returns {string} | ||
*/ | ||
export function zlib_decode(base_compressed: string): any; | ||
export function zlib_decode(base_compressed: string): string; | ||
/** | ||
@@ -69,3 +69,3 @@ * @param {string} base_raw | ||
readonly memory: WebAssembly.Memory; | ||
readonly zlib_decode: (a: number, b: number) => number; | ||
readonly zlib_decode: (a: number, b: number, c: number) => void; | ||
readonly zlib_encode: (a: number, b: number, c: number) => void; | ||
@@ -82,5 +82,5 @@ readonly gzip_decode: (a: number, b: number, c: number) => void; | ||
readonly deflate_encode_raw: (a: number, b: number, c: number) => void; | ||
readonly __wbindgen_add_to_stack_pointer: (a: number) => number; | ||
readonly __wbindgen_malloc: (a: number, b: number) => number; | ||
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number; | ||
readonly __wbindgen_add_to_stack_pointer: (a: number) => number; | ||
readonly __wbindgen_free: (a: number, b: number, c: number) => void; | ||
@@ -87,0 +87,0 @@ } |
let wasm; | ||
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); | ||
let WASM_VECTOR_LEN = 0; | ||
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; | ||
let cachedUint8Memory0 = null; | ||
@@ -16,24 +14,2 @@ | ||
function getStringFromWasm0(ptr, len) { | ||
ptr = ptr >>> 0; | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
const heap = new Array(128).fill(undefined); | ||
heap.push(undefined, null, true, false); | ||
let heap_next = heap.length; | ||
function addHeapObject(obj) { | ||
if (heap_next === heap.length) heap.push(heap.length + 1); | ||
const idx = heap_next; | ||
heap_next = heap[idx]; | ||
heap[idx] = obj; | ||
return idx; | ||
} | ||
let WASM_VECTOR_LEN = 0; | ||
const cachedTextEncoder = (typeof TextEncoder !== 'undefined' ? new TextEncoder('utf-8') : { encode: () => { throw Error('TextEncoder not available') } } ); | ||
@@ -92,34 +68,42 @@ | ||
function getObject(idx) { return heap[idx]; } | ||
let cachedInt32Memory0 = null; | ||
function dropObject(idx) { | ||
if (idx < 132) return; | ||
heap[idx] = heap_next; | ||
heap_next = idx; | ||
function getInt32Memory0() { | ||
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { | ||
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); | ||
} | ||
return cachedInt32Memory0; | ||
} | ||
function takeObject(idx) { | ||
const ret = getObject(idx); | ||
dropObject(idx); | ||
return ret; | ||
const cachedTextDecoder = (typeof TextDecoder !== 'undefined' ? new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }) : { decode: () => { throw Error('TextDecoder not available') } } ); | ||
if (typeof TextDecoder !== 'undefined') { cachedTextDecoder.decode(); }; | ||
function getStringFromWasm0(ptr, len) { | ||
ptr = ptr >>> 0; | ||
return cachedTextDecoder.decode(getUint8Memory0().subarray(ptr, ptr + len)); | ||
} | ||
/** | ||
* @param {string} base_compressed | ||
* @returns {any} | ||
* @returns {string} | ||
*/ | ||
export function zlib_decode(base_compressed) { | ||
const ptr0 = passStringToWasm0(base_compressed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ret = wasm.zlib_decode(ptr0, len0); | ||
return takeObject(ret); | ||
let deferred2_0; | ||
let deferred2_1; | ||
try { | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
const ptr0 = passStringToWasm0(base_compressed, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
wasm.zlib_decode(retptr, ptr0, len0); | ||
var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
var r1 = getInt32Memory0()[retptr / 4 + 1]; | ||
deferred2_0 = r0; | ||
deferred2_1 = r1; | ||
return getStringFromWasm0(r0, r1); | ||
} finally { | ||
wasm.__wbindgen_add_to_stack_pointer(16); | ||
wasm.__wbindgen_free(deferred2_0, deferred2_1, 1); | ||
} | ||
} | ||
let cachedInt32Memory0 = null; | ||
function getInt32Memory0() { | ||
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { | ||
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); | ||
} | ||
return cachedInt32Memory0; | ||
} | ||
/** | ||
@@ -405,6 +389,2 @@ * @param {string} base_raw | ||
imports.wbg = {}; | ||
imports.wbg.__wbindgen_string_new = function(arg0, arg1) { | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
}; | ||
@@ -411,0 +391,0 @@ return imports; |
Sorry, the diff of this file is not supported yet
137031
484