UNPKG

kitoken

Version:

Fast and versatile tokenizer for language models, supporting BPE, Unigram and WordPiece tokenization

846 lines (752 loc) 28.1 kB
let imports = {}; imports['__wbindgen_placeholder__'] = module.exports; let wasm; const { TextEncoder, TextDecoder } = require(`util`); const heap = new Array(128).fill(undefined); heap.push(undefined, null, true, false); function getObject(idx) { return heap[idx]; } let WASM_VECTOR_LEN = 0; let cachedUint8ArrayMemory0 = null; function getUint8ArrayMemory0() { if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) { cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer); } return cachedUint8ArrayMemory0; } let cachedTextEncoder = new TextEncoder('utf-8'); const encodeString = (typeof cachedTextEncoder.encodeInto === 'function' ? function (arg, view) { return cachedTextEncoder.encodeInto(arg, view); } : function (arg, view) { const buf = cachedTextEncoder.encode(arg); view.set(buf); return { read: arg.length, written: buf.length }; }); function passStringToWasm0(arg, malloc, realloc) { if (realloc === undefined) { const buf = cachedTextEncoder.encode(arg); const ptr = malloc(buf.length, 1) >>> 0; getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf); WASM_VECTOR_LEN = buf.length; return ptr; } let len = arg.length; let ptr = malloc(len, 1) >>> 0; const mem = getUint8ArrayMemory0(); let offset = 0; for (; offset < len; offset++) { const code = arg.charCodeAt(offset); if (code > 0x7F) break; mem[ptr + offset] = code; } if (offset !== len) { if (offset !== 0) { arg = arg.slice(offset); } ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0; const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len); const ret = encodeString(arg, view); offset += ret.written; ptr = realloc(ptr, len, offset, 1) >>> 0; } WASM_VECTOR_LEN = offset; return ptr; } let cachedDataViewMemory0 = null; function getDataViewMemory0() { if (cachedDataViewMemory0 === null || cachedDataViewMemory0.buffer.detached === true || (cachedDataViewMemory0.buffer.detached === undefined && cachedDataViewMemory0.buffer !== wasm.memory.buffer)) { cachedDataViewMemory0 = new DataView(wasm.memory.buffer); } return cachedDataViewMemory0; } 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; } function handleError(f, args) { try { return f.apply(this, args); } catch (e) { wasm.__wbindgen_export_2(addHeapObject(e)); } } function dropObject(idx) { if (idx < 132) return; heap[idx] = heap_next; heap_next = idx; } function takeObject(idx) { const ret = getObject(idx); dropObject(idx); return ret; } function debugString(val) { // primitive types const type = typeof val; if (type == 'number' || type == 'boolean' || val == null) { return `${val}`; } if (type == 'string') { return `"${val}"`; } if (type == 'symbol') { const description = val.description; if (description == null) { return 'Symbol'; } else { return `Symbol(${description})`; } } if (type == 'function') { const name = val.name; if (typeof name == 'string' && name.length > 0) { return `Function(${name})`; } else { return 'Function'; } } // objects if (Array.isArray(val)) { const length = val.length; let debug = '['; if (length > 0) { debug += debugString(val[0]); } for(let i = 1; i < length; i++) { debug += ', ' + debugString(val[i]); } debug += ']'; return debug; } // Test for built-in const builtInMatches = /\[object ([^\]]+)\]/.exec(toString.call(val)); let className; if (builtInMatches && builtInMatches.length > 1) { className = builtInMatches[1]; } else { // Failed to match the standard '[object ClassName]' return toString.call(val); } if (className == 'Object') { // we're a user defined class or Object // JSON.stringify avoids problems with cycles, and is generally much // easier than looping through ownProperties of `val`. try { return 'Object(' + JSON.stringify(val) + ')'; } catch (_) { return 'Object'; } } // errors if (val instanceof Error) { return `${val.name}: ${val.message}\n${val.stack}`; } // TODO we could test for more things here, like `Set`s and `Map`s. return className; } let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); cachedTextDecoder.decode(); function getStringFromWasm0(ptr, len) { ptr = ptr >>> 0; return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len)); } function isLikeNone(x) { return x === undefined || x === null; } let cachedUint32ArrayMemory0 = null; function getUint32ArrayMemory0() { if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) { cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer); } return cachedUint32ArrayMemory0; } function getArrayU32FromWasm0(ptr, len) { ptr = ptr >>> 0; return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len); } function getArrayU8FromWasm0(ptr, len) { ptr = ptr >>> 0; return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len); } 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 passArrayJsValueToWasm0(array, malloc) { const ptr = malloc(array.length * 4, 4) >>> 0; const mem = getDataViewMemory0(); for (let i = 0; i < array.length; i++) { mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true); } WASM_VECTOR_LEN = array.length; return ptr; } function getArrayJsValueFromWasm0(ptr, len) { ptr = ptr >>> 0; const mem = getDataViewMemory0(); const result = []; for (let i = ptr; i < ptr + 4 * len; i += 4) { result.push(takeObject(mem.getUint32(i, true))); } return result; } function passArray32ToWasm0(arg, malloc) { const ptr = malloc(arg.length * 4, 4) >>> 0; getUint32ArrayMemory0().set(arg, ptr / 4); WASM_VECTOR_LEN = arg.length; return ptr; } const KitokenFinalization = (typeof FinalizationRegistry === 'undefined') ? { register: () => {}, unregister: () => {} } : new FinalizationRegistry(ptr => wasm.__wbg_kitoken_free(ptr >>> 0, 1)); /** * Kitoken tokenizer. * A fast and versatile tokenizer for language models. */ class Kitoken { static __wrap(ptr) { ptr = ptr >>> 0; const obj = Object.create(Kitoken.prototype); obj.__wbg_ptr = ptr; KitokenFinalization.register(obj, obj.__wbg_ptr, obj); return obj; } __destroy_into_raw() { const ptr = this.__wbg_ptr; this.__wbg_ptr = 0; KitokenFinalization.unregister(this); return ptr; } free() { const ptr = this.__destroy_into_raw(); wasm.__wbg_kitoken_free(ptr, 0); } /** * Initializes the tokenizer from a serialized `kitoken` definition. * @param {Uint8Array} data */ constructor(data) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.kitoken_new(retptr, ptr0, len0); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } this.__wbg_ptr = r0 >>> 0; KitokenFinalization.register(this, this.__wbg_ptr, this); return this; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Encodes the given text into a sequence of tokens. * * If `encode_specials` is `true`, the text is first split around special tokens which are separately encoded with the special encoder. * * Returns a list of tokens, or an error if no token for a part exists in the encoder and no unknown token id is set in the configuration. * @param {string} text * @param {boolean | undefined} [encode_specials] * @returns {Uint32Array} */ encode(text, encode_specials) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passStringToWasm0(text, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); const len0 = WASM_VECTOR_LEN; wasm.kitoken_encode(retptr, this.__wbg_ptr, ptr0, len0, isLikeNone(encode_specials) ? 0xFFFFFF : encode_specials ? 1 : 0); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); if (r3) { throw takeObject(r2); } var v2 = getArrayU32FromWasm0(r0, r1).slice(); wasm.__wbindgen_export_3(r0, r1 * 4, 4); return v2; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Encodes the given texts into sequences of tokens. * * If `encode_specials` is `true`, the text is first split around special tokens which are separately encoded with the special encoder. * * Returns a list of lists of tokens, or an error if no token for a part exists in the encoder and no unknown token id is set in the configuration. * @param {(string)[]} text * @param {boolean | undefined} [encode_specials] * @returns {any[]} */ encode_all(text, encode_specials) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArrayJsValueToWasm0(text, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.kitoken_encode_all(retptr, this.__wbg_ptr, ptr0, len0, isLikeNone(encode_specials) ? 0xFFFFFF : encode_specials ? 1 : 0); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); if (r3) { throw takeObject(r2); } var v2 = getArrayJsValueFromWasm0(r0, r1).slice(); wasm.__wbindgen_export_3(r0, r1 * 4, 4); return v2; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Decodes the given sequence of tokens into text. * * Returns a list of bytes, or an error if no byte sequence for a token exists in the decoder and no unknown token is set in the configuration. * @param {Uint32Array} tokens * @param {boolean | undefined} [decode_specials] * @returns {Uint8Array} */ decode(tokens, decode_specials) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray32ToWasm0(tokens, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.kitoken_decode(retptr, this.__wbg_ptr, ptr0, len0, isLikeNone(decode_specials) ? 0xFFFFFF : decode_specials ? 1 : 0); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); if (r3) { throw takeObject(r2); } var v2 = getArrayU8FromWasm0(r0, r1).slice(); wasm.__wbindgen_export_3(r0, r1 * 1, 1); return v2; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Decodes the given sequences of tokens into texts. * * Returns a list of lists of bytes, or an error if no byte sequence for a token exists in the decoder and no unknown token is set in the configuration. * @param {any[]} tokens * @param {boolean | undefined} [decode_specials] * @returns {any[]} */ decode_all(tokens, decode_specials) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArrayJsValueToWasm0(tokens, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.kitoken_decode_all(retptr, this.__wbg_ptr, ptr0, len0, isLikeNone(decode_specials) ? 0xFFFFFF : decode_specials ? 1 : 0); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true); if (r3) { throw takeObject(r2); } var v2 = getArrayJsValueFromWasm0(r0, r1).slice(); wasm.__wbindgen_export_3(r0, r1 * 4, 4); return v2; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Returns the definition of the tokenizer. * @returns {any} */ definition() { const ret = wasm.kitoken_definition(this.__wbg_ptr); return takeObject(ret); } /** * Sets the definition of the tokenizer. * * Returns an error if the definition is invalid. * @param {any} definition */ set_definition(definition) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.kitoken_set_definition(retptr, this.__wbg_ptr, addHeapObject(definition)); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Returns the configuration of the tokenizer. * @returns {any} */ config() { const ret = wasm.kitoken_config(this.__wbg_ptr); return takeObject(ret); } /** * Sets the configuration of the tokenizer. * * Returns an error if the configuration is invalid. * @param {any} config */ set_config(config) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.kitoken_set_config(retptr, this.__wbg_ptr, addHeapObject(config)); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); if (r1) { throw takeObject(r0); } } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Creates a definition from this tokenizer and serializes it to bytes. * @returns {Uint8Array} */ to_bytes() { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); wasm.kitoken_to_bytes(retptr, this.__wbg_ptr); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var v1 = getArrayU8FromWasm0(r0, r1).slice(); wasm.__wbindgen_export_3(r0, r1 * 1, 1); return v1; } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Initializes the tokenizer from a serialized `sentencepiece` model. * @param {Uint8Array} data * @returns {Kitoken} */ static from_sentencepiece(data) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.kitoken_from_sentencepiece(retptr, ptr0, len0); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return Kitoken.__wrap(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Initializes the tokenizer from a serialized `tiktoken` model. * @param {Uint8Array} data * @returns {Kitoken} */ static from_tiktoken(data) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.kitoken_from_tiktoken(retptr, ptr0, len0); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return Kitoken.__wrap(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Initializes the tokenizer from a serialized `tokenizers` model. * @param {Uint8Array} data * @returns {Kitoken} */ static from_tokenizers(data) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.kitoken_from_tokenizers(retptr, ptr0, len0); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return Kitoken.__wrap(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } /** * Initializes the tokenizer from a serialized `tokenizers` model. * @param {Uint8Array} data * @returns {Kitoken} */ static from_tekken(data) { try { const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); const ptr0 = passArray8ToWasm0(data, wasm.__wbindgen_export_0); const len0 = WASM_VECTOR_LEN; wasm.kitoken_from_tekken(retptr, ptr0, len0); var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true); var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true); var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true); if (r2) { throw takeObject(r1); } return Kitoken.__wrap(r0); } finally { wasm.__wbindgen_add_to_stack_pointer(16); } } } module.exports.Kitoken = Kitoken; module.exports.__wbg_String_8f0eb39a4a4c2f66 = function(arg0, arg1) { const ret = String(getObject(arg1)); const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); const len1 = WASM_VECTOR_LEN; getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); }; module.exports.__wbg_buffer_61b7ce01341d7f88 = function(arg0) { const ret = getObject(arg0).buffer; return addHeapObject(ret); }; module.exports.__wbg_call_b0d8e36992d9900d = function() { return handleError(function (arg0, arg1) { const ret = getObject(arg0).call(getObject(arg1)); return addHeapObject(ret); }, arguments) }; module.exports.__wbg_codePointAt_93f466f2352273c3 = function(arg0, arg1) { const ret = getObject(arg0).codePointAt(arg1 >>> 0); return addHeapObject(ret); }; module.exports.__wbg_done_f22c1561fa919baa = function(arg0) { const ret = getObject(arg0).done; return ret; }; module.exports.__wbg_entries_4f2bb9b0d701c0f6 = function(arg0) { const ret = Object.entries(getObject(arg0)); return addHeapObject(ret); }; module.exports.__wbg_fromCodePoint_ef89154c4db48bdf = function() { return handleError(function (arg0) { const ret = String.fromCodePoint(arg0 >>> 0); return addHeapObject(ret); }, arguments) }; module.exports.__wbg_get_9aa3dff3f0266054 = function(arg0, arg1) { const ret = getObject(arg0)[arg1 >>> 0]; return addHeapObject(ret); }; module.exports.__wbg_get_bbccf8970793c087 = function() { return handleError(function (arg0, arg1) { const ret = Reflect.get(getObject(arg0), getObject(arg1)); return addHeapObject(ret); }, arguments) }; module.exports.__wbg_getwithrefkey_1dc361bd10053bfe = function(arg0, arg1) { const ret = getObject(arg0)[getObject(arg1)]; return addHeapObject(ret); }; module.exports.__wbg_instanceof_ArrayBuffer_670ddde44cdb2602 = function(arg0) { let result; try { result = getObject(arg0) instanceof ArrayBuffer; } catch (_) { result = false; } const ret = result; return ret; }; module.exports.__wbg_instanceof_Uint8Array_28af5bc19d6acad8 = function(arg0) { let result; try { result = getObject(arg0) instanceof Uint8Array; } catch (_) { result = false; } const ret = result; return ret; }; module.exports.__wbg_isArray_1ba11a930108ec51 = function(arg0) { const ret = Array.isArray(getObject(arg0)); return ret; }; module.exports.__wbg_isSafeInteger_12f5549b2fca23f4 = function(arg0) { const ret = Number.isSafeInteger(getObject(arg0)); return ret; }; module.exports.__wbg_iterator_23604bb983791576 = function() { const ret = Symbol.iterator; return addHeapObject(ret); }; module.exports.__wbg_length_15aa023b16db5413 = function(arg0) { const ret = getObject(arg0).length; return ret; }; module.exports.__wbg_length_65d1cd11729ced11 = function(arg0) { const ret = getObject(arg0).length; return ret; }; module.exports.__wbg_length_d65cf0786bfc5739 = function(arg0) { const ret = getObject(arg0).length; return ret; }; module.exports.__wbg_new_254fa9eac11932ae = function() { const ret = new Array(); return addHeapObject(ret); }; module.exports.__wbg_new_3ff5b33b1ce712df = function(arg0) { const ret = new Uint8Array(getObject(arg0)); return addHeapObject(ret); }; module.exports.__wbg_new_688846f374351c92 = function() { const ret = new Object(); return addHeapObject(ret); }; module.exports.__wbg_next_01dd9234a5bf6d05 = function() { return handleError(function (arg0) { const ret = getObject(arg0).next(); return addHeapObject(ret); }, arguments) }; module.exports.__wbg_next_137428deb98342b0 = function(arg0) { const ret = getObject(arg0).next; return addHeapObject(ret); }; module.exports.__wbg_set_1d80752d0d5f0b21 = function(arg0, arg1, arg2) { getObject(arg0)[arg1 >>> 0] = takeObject(arg2); }; module.exports.__wbg_set_23d69db4e5c66a6e = function(arg0, arg1, arg2) { getObject(arg0).set(getObject(arg1), arg2 >>> 0); }; module.exports.__wbg_set_3f1d0b984ed272ed = function(arg0, arg1, arg2) { getObject(arg0)[takeObject(arg1)] = takeObject(arg2); }; module.exports.__wbg_value_4c32fd138a88eee2 = function(arg0) { const ret = getObject(arg0).value; return addHeapObject(ret); }; module.exports.__wbindgen_as_number = function(arg0) { const ret = +getObject(arg0); return ret; }; module.exports.__wbindgen_boolean_get = function(arg0) { const v = getObject(arg0); const ret = typeof(v) === 'boolean' ? (v ? 1 : 0) : 2; return ret; }; module.exports.__wbindgen_debug_string = function(arg0, arg1) { const ret = debugString(getObject(arg1)); const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); const len1 = WASM_VECTOR_LEN; getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); }; module.exports.__wbindgen_error_new = function(arg0, arg1) { const ret = new Error(getStringFromWasm0(arg0, arg1)); return addHeapObject(ret); }; module.exports.__wbindgen_in = function(arg0, arg1) { const ret = getObject(arg0) in getObject(arg1); return ret; }; module.exports.__wbindgen_is_function = function(arg0) { const ret = typeof(getObject(arg0)) === 'function'; return ret; }; module.exports.__wbindgen_is_object = function(arg0) { const val = getObject(arg0); const ret = typeof(val) === 'object' && val !== null; return ret; }; module.exports.__wbindgen_is_string = function(arg0) { const ret = typeof(getObject(arg0)) === 'string'; return ret; }; module.exports.__wbindgen_is_undefined = function(arg0) { const ret = getObject(arg0) === undefined; return ret; }; module.exports.__wbindgen_jsval_loose_eq = function(arg0, arg1) { const ret = getObject(arg0) == getObject(arg1); return ret; }; module.exports.__wbindgen_memory = function() { const ret = wasm.memory; return addHeapObject(ret); }; module.exports.__wbindgen_number_get = function(arg0, arg1) { const obj = getObject(arg1); const ret = typeof(obj) === 'number' ? obj : undefined; getDataViewMemory0().setFloat64(arg0 + 8 * 1, isLikeNone(ret) ? 0 : ret, true); getDataViewMemory0().setInt32(arg0 + 4 * 0, !isLikeNone(ret), true); }; module.exports.__wbindgen_number_new = function(arg0) { const ret = arg0; return addHeapObject(ret); }; module.exports.__wbindgen_object_clone_ref = function(arg0) { const ret = getObject(arg0); return addHeapObject(ret); }; module.exports.__wbindgen_object_drop_ref = function(arg0) { takeObject(arg0); }; module.exports.__wbindgen_string_get = function(arg0, arg1) { const obj = getObject(arg1); const ret = typeof(obj) === 'string' ? obj : undefined; var ptr1 = isLikeNone(ret) ? 0 : passStringToWasm0(ret, wasm.__wbindgen_export_0, wasm.__wbindgen_export_1); var len1 = WASM_VECTOR_LEN; getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true); getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true); }; module.exports.__wbindgen_string_new = function(arg0, arg1) { const ret = getStringFromWasm0(arg0, arg1); return addHeapObject(ret); }; module.exports.__wbindgen_throw = function(arg0, arg1) { throw new Error(getStringFromWasm0(arg0, arg1)); }; module.exports.__wbindgen_uint32_array_new = function(arg0, arg1) { var v0 = getArrayU32FromWasm0(arg0, arg1).slice(); wasm.__wbindgen_export_3(arg0, arg1 * 4, 4); const ret = v0; return addHeapObject(ret); }; module.exports.__wbindgen_uint8_array_new = function(arg0, arg1) { var v0 = getArrayU8FromWasm0(arg0, arg1).slice(); wasm.__wbindgen_export_3(arg0, arg1 * 1, 1); const ret = v0; return addHeapObject(ret); }; const path = require('path').join(__dirname, 'node_bg.wasm'); const bytes = require('fs').readFileSync(path); const wasmModule = new WebAssembly.Module(bytes); const wasmInstance = new WebAssembly.Instance(wasmModule, imports); wasm = wasmInstance.exports; module.exports.__wasm = wasm;