diff --git a/pkg/scheduler.d.ts b/pkg/scheduler.d.ts index bee3360d1..0966b36d1 100644 --- a/pkg/scheduler.d.ts +++ b/pkg/scheduler.d.ts @@ -1,14 +1,11 @@ /* tslint:disable */ /* eslint-disable */ - -import { ISchedulerInput, ISchedulerOutput } from "@src/Interfaces/IScheduler"; - /** * The main wasm function to call - * @param {ISchedulerInput} input - * @returns {ISchedulerOutput} + * @param {any} input + * @returns {any} */ -export function schedule(input: ISchedulerInput): ISchedulerOutput | undefined; +export function schedule(input: any): any; interface Input { startDate: string; diff --git a/pkg/scheduler.js b/pkg/scheduler.js index e2d5ab236..3aafb9e83 100644 --- a/pkg/scheduler.js +++ b/pkg/scheduler.js @@ -1,5 +1,36 @@ let wasm; +const heap = new Array(128).fill(undefined); + +heap.push(undefined, null, true, false); + +function getObject(idx) { + return heap[idx]; +} + +let heap_next = heap.length; + +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 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; +} + const cachedTextDecoder = typeof TextDecoder !== "undefined" ? new TextDecoder("utf-8", { ignoreBOM: true, fatal: true }) @@ -27,33 +58,6 @@ function getStringFromWasm0(ptr, len) { 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]; - - if (typeof heap_next !== "number") throw new Error("corrupt heap"); - - heap[idx] = obj; - return idx; -} - -function getObject(idx) { - return heap[idx]; -} - -function _assertBoolean(n) { - if (typeof n !== "boolean") { - throw new Error(`expected a boolean argument, found ${typeof n}`); - } -} - let WASM_VECTOR_LEN = 0; const cachedTextEncoder = @@ -80,8 +84,6 @@ const encodeString = }; function passStringToWasm0(arg, malloc, realloc) { - if (typeof arg !== "string") throw new Error(`expected a string argument, found ${typeof arg}`); - if (realloc === undefined) { const buf = cachedTextEncoder.encode(arg); const ptr = malloc(buf.length, 1) >>> 0; @@ -112,7 +114,7 @@ function passStringToWasm0(arg, malloc, realloc) { ptr = realloc(ptr, len, (len = offset + arg.length * 3), 1) >>> 0; const view = getUint8Memory0().subarray(ptr + offset, ptr + len); const ret = encodeString(arg, view); - if (ret.read !== arg.length) throw new Error("failed to pass whole string"); + offset += ret.written; ptr = realloc(ptr, len, offset, 1) >>> 0; } @@ -134,10 +136,6 @@ function getInt32Memory0() { return cachedInt32Memory0; } -function _assertNum(n) { - if (typeof n !== "number") throw new Error(`expected a number argument, found ${typeof n}`); -} - let cachedFloat64Memory0 = null; function getFloat64Memory0() { @@ -147,6 +145,15 @@ function getFloat64Memory0() { return cachedFloat64Memory0; } +let cachedBigInt64Memory0 = null; + +function getBigInt64Memory0() { + if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) { + cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer); + } + return cachedBigInt64Memory0; +} + function debugString(val) { // primitive types const type = typeof val; @@ -212,31 +219,6 @@ function debugString(val) { return className; } -function _assertBigInt(n) { - if (typeof n !== "bigint") throw new Error(`expected a bigint argument, found ${typeof n}`); -} - -let cachedBigInt64Memory0 = null; - -function getBigInt64Memory0() { - if (cachedBigInt64Memory0 === null || cachedBigInt64Memory0.byteLength === 0) { - cachedBigInt64Memory0 = new BigInt64Array(wasm.memory.buffer); - } - return cachedBigInt64Memory0; -} - -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; -} - let stack_pointer = 128; function addBorrowedObject(obj) { @@ -266,22 +248,6 @@ export function schedule(input) { } } -function logError(f, args) { - try { - return f.apply(this, args); - } catch (e) { - let error = (function () { - try { - return e instanceof Error ? `${e.message}\n\nStack:\n${e.stack}` : e.toString(); - } catch (_) { - return ""; - } - })(); - console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", error); - throw e; - } -} - function handleError(f, args) { try { return f.apply(this, args); @@ -323,20 +289,25 @@ async function __wbg_load(module, imports) { function __wbg_get_imports() { const imports = {}; imports.wbg = {}; - imports.wbg.__wbindgen_error_new = function (arg0, arg1) { - const ret = new Error(getStringFromWasm0(arg0, arg1)); - return addHeapObject(ret); + imports.wbg.__wbindgen_object_drop_ref = function (arg0) { + takeObject(arg0); }; - imports.wbg.__wbindgen_is_undefined = function (arg0) { - const ret = getObject(arg0) === undefined; - _assertBoolean(ret); + imports.wbg.__wbindgen_is_bigint = function (arg0) { + const ret = typeof getObject(arg0) === "bigint"; return ret; }; - imports.wbg.__wbindgen_in = function (arg0, arg1) { - const ret = getObject(arg0) in getObject(arg1); - _assertBoolean(ret); + imports.wbg.__wbindgen_bigint_from_u64 = function (arg0) { + const ret = BigInt.asUintN(64, arg0); + return addHeapObject(ret); + }; + imports.wbg.__wbindgen_jsval_eq = function (arg0, arg1) { + const ret = getObject(arg0) === getObject(arg1); return ret; }; + imports.wbg.__wbindgen_error_new = function (arg0, arg1) { + const ret = new Error(getStringFromWasm0(arg0, arg1)); + return addHeapObject(ret); + }; imports.wbg.__wbindgen_string_get = function (arg0, arg1) { const obj = getObject(arg1); const ret = typeof obj === "string" ? obj : undefined; @@ -345,72 +316,66 @@ function __wbg_get_imports() { getInt32Memory0()[arg0 / 4 + 1] = len1; getInt32Memory0()[arg0 / 4 + 0] = ptr1; }; - imports.wbg.__wbindgen_is_bigint = function (arg0) { - const ret = typeof getObject(arg0) === "bigint"; - _assertBoolean(ret); - return ret; - }; imports.wbg.__wbindgen_is_object = function (arg0) { const val = getObject(arg0); const ret = typeof val === "object" && val !== null; - _assertBoolean(ret); + return ret; + }; + imports.wbg.__wbindgen_is_undefined = function (arg0) { + const ret = getObject(arg0) === undefined; + return ret; + }; + imports.wbg.__wbindgen_in = function (arg0, arg1) { + const ret = getObject(arg0) in getObject(arg1); return ret; }; imports.wbg.__wbindgen_object_clone_ref = function (arg0) { const ret = getObject(arg0); return addHeapObject(ret); }; - imports.wbg.__wbindgen_jsval_eq = function (arg0, arg1) { - const ret = getObject(arg0) === getObject(arg1); - _assertBoolean(ret); - return ret; - }; - imports.wbg.__wbindgen_bigint_from_u64 = function (arg0) { - const ret = BigInt.asUintN(64, arg0); + imports.wbg.__wbg_new_abda76e883ba8a5f = function () { + const ret = new Error(); return addHeapObject(ret); }; - imports.wbg.__wbg_error_f851667af71bcfc6 = function () { - return logError(function (arg0, arg1) { - let deferred0_0; - let deferred0_1; - try { - deferred0_0 = arg0; - deferred0_1 = arg1; - console.error(getStringFromWasm0(arg0, arg1)); - } finally { - wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); - } - }, arguments); + imports.wbg.__wbg_stack_658279fe44541cf6 = function (arg0, arg1) { + const ret = getObject(arg1).stack; + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; }; - imports.wbg.__wbg_new_abda76e883ba8a5f = function () { - return logError(function () { - const ret = new Error(); - return addHeapObject(ret); - }, arguments); + imports.wbg.__wbg_error_f851667af71bcfc6 = function (arg0, arg1) { + let deferred0_0; + let deferred0_1; + try { + deferred0_0 = arg0; + deferred0_1 = arg1; + console.error(getStringFromWasm0(arg0, arg1)); + } finally { + wasm.__wbindgen_free(deferred0_0, deferred0_1, 1); + } }; - imports.wbg.__wbg_stack_658279fe44541cf6 = function () { - return logError(function (arg0, arg1) { - const ret = getObject(arg1).stack; - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len1; - getInt32Memory0()[arg0 / 4 + 0] = ptr1; - }, arguments); + imports.wbg.__wbindgen_jsval_loose_eq = function (arg0, arg1) { + const ret = getObject(arg0) == getObject(arg1); + return ret; + }; + imports.wbg.__wbindgen_boolean_get = function (arg0) { + const v = getObject(arg0); + const ret = typeof v === "boolean" ? (v ? 1 : 0) : 2; + return ret; }; imports.wbg.__wbindgen_number_get = function (arg0, arg1) { const obj = getObject(arg1); const ret = typeof obj === "number" ? obj : undefined; - if (!isLikeNone(ret)) { - _assertNum(ret); - } getFloat64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? 0 : ret; getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); }; - imports.wbg.__wbindgen_boolean_get = function (arg0) { - const v = getObject(arg0); - const ret = typeof v === "boolean" ? (v ? 1 : 0) : 2; - _assertNum(ret); - return ret; + imports.wbg.__wbg_String_88810dfeb4021902 = function (arg0, arg1) { + const ret = String(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; }; imports.wbg.__wbindgen_number_new = function (arg0) { const ret = arg0; @@ -420,80 +385,32 @@ function __wbg_get_imports() { const ret = getStringFromWasm0(arg0, arg1); return addHeapObject(ret); }; - imports.wbg.__wbindgen_jsval_loose_eq = function (arg0, arg1) { - const ret = getObject(arg0) == getObject(arg1); - _assertBoolean(ret); - return ret; + imports.wbg.__wbg_getwithrefkey_5e6d9547403deab8 = function (arg0, arg1) { + const ret = getObject(arg0)[getObject(arg1)]; + return addHeapObject(ret); }; - imports.wbg.__wbg_String_88810dfeb4021902 = function () { - return logError(function (arg0, arg1) { - const ret = String(getObject(arg1)); - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len1; - getInt32Memory0()[arg0 / 4 + 0] = ptr1; - }, arguments); + imports.wbg.__wbg_set_841ac57cff3d672b = function (arg0, arg1, arg2) { + getObject(arg0)[takeObject(arg1)] = takeObject(arg2); }; - imports.wbg.__wbg_getwithrefkey_5e6d9547403deab8 = function () { - return logError(function (arg0, arg1) { - const ret = getObject(arg0)[getObject(arg1)]; - return addHeapObject(ret); - }, arguments); + imports.wbg.__wbg_get_4a9aa5157afeb382 = function (arg0, arg1) { + const ret = getObject(arg0)[arg1 >>> 0]; + return addHeapObject(ret); }; - imports.wbg.__wbg_set_841ac57cff3d672b = function () { - return logError(function (arg0, arg1, arg2) { - getObject(arg0)[takeObject(arg1)] = takeObject(arg2); - }, arguments); + imports.wbg.__wbg_length_cace2e0b3ddc0502 = function (arg0) { + const ret = getObject(arg0).length; + return ret; }; imports.wbg.__wbg_new_08236689f0afb357 = function () { - return logError(function () { - const ret = new Array(); - return addHeapObject(ret); - }, arguments); - }; - imports.wbg.__wbg_get_4a9aa5157afeb382 = function () { - return logError(function (arg0, arg1) { - const ret = getObject(arg0)[arg1 >>> 0]; - return addHeapObject(ret); - }, arguments); - }; - imports.wbg.__wbg_set_0ac78a2bc07da03c = function () { - return logError(function (arg0, arg1, arg2) { - getObject(arg0)[arg1 >>> 0] = takeObject(arg2); - }, arguments); - }; - imports.wbg.__wbg_isArray_38525be7442aa21e = function () { - return logError(function (arg0) { - const ret = Array.isArray(getObject(arg0)); - _assertBoolean(ret); - return ret; - }, arguments); - }; - imports.wbg.__wbg_length_cace2e0b3ddc0502 = function () { - return logError(function (arg0) { - const ret = getObject(arg0).length; - _assertNum(ret); - return ret; - }, arguments); + const ret = new Array(); + return addHeapObject(ret); }; - imports.wbg.__wbg_instanceof_ArrayBuffer_c7cc317e5c29cc0d = function () { - return logError(function (arg0) { - let result; - try { - result = getObject(arg0) instanceof ArrayBuffer; - } catch (_) { - result = false; - } - const ret = result; - _assertBoolean(ret); - return ret; - }, arguments); + imports.wbg.__wbindgen_is_function = function (arg0) { + const ret = typeof getObject(arg0) === "function"; + return ret; }; - imports.wbg.__wbg_call_669127b9d730c650 = function () { - return handleError(function (arg0, arg1) { - const ret = getObject(arg0).call(getObject(arg1)); - return addHeapObject(ret); - }, arguments); + imports.wbg.__wbg_next_15da6a3df9290720 = function (arg0) { + const ret = getObject(arg0).next; + return addHeapObject(ret); }; imports.wbg.__wbg_next_1989a20442400aaa = function () { return handleError(function (arg0) { @@ -501,110 +418,92 @@ function __wbg_get_imports() { return addHeapObject(ret); }, arguments); }; - imports.wbg.__wbg_next_15da6a3df9290720 = function () { - return logError(function (arg0) { - const ret = getObject(arg0).next; - return addHeapObject(ret); - }, arguments); - }; - imports.wbg.__wbg_done_bc26bf4ada718266 = function () { - return logError(function (arg0) { - const ret = getObject(arg0).done; - _assertBoolean(ret); - return ret; - }, arguments); + imports.wbg.__wbg_done_bc26bf4ada718266 = function (arg0) { + const ret = getObject(arg0).done; + return ret; }; - imports.wbg.__wbg_value_0570714ff7d75f35 = function () { - return logError(function (arg0) { - const ret = getObject(arg0).value; - return addHeapObject(ret); - }, arguments); + imports.wbg.__wbg_value_0570714ff7d75f35 = function (arg0) { + const ret = getObject(arg0).value; + return addHeapObject(ret); }; - imports.wbg.__wbg_isSafeInteger_c38b0a16d0c7cef7 = function () { - return logError(function (arg0) { - const ret = Number.isSafeInteger(getObject(arg0)); - _assertBoolean(ret); - return ret; - }, arguments); + imports.wbg.__wbg_iterator_7ee1a391d310f8e4 = function () { + const ret = Symbol.iterator; + return addHeapObject(ret); }; - imports.wbg.__wbg_new_c728d68b8b34487e = function () { - return logError(function () { - const ret = new Object(); + imports.wbg.__wbg_get_2aff440840bb6202 = function () { + return handleError(function (arg0, arg1) { + const ret = Reflect.get(getObject(arg0), getObject(arg1)); return addHeapObject(ret); }, arguments); }; - imports.wbg.__wbg_iterator_7ee1a391d310f8e4 = function () { - return logError(function () { - const ret = Symbol.iterator; + imports.wbg.__wbg_call_669127b9d730c650 = function () { + return handleError(function (arg0, arg1) { + const ret = getObject(arg0).call(getObject(arg1)); return addHeapObject(ret); }, arguments); }; - imports.wbg.__wbg_instanceof_Uint8Array_19e6f142a5e7e1e1 = function () { - return logError(function (arg0) { - let result; - try { - result = getObject(arg0) instanceof Uint8Array; - } catch (_) { - result = false; - } - const ret = result; - _assertBoolean(ret); - return ret; - }, arguments); + imports.wbg.__wbg_new_c728d68b8b34487e = function () { + const ret = new Object(); + return addHeapObject(ret); }; - imports.wbg.__wbg_new_d8a000788389a31e = function () { - return logError(function (arg0) { - const ret = new Uint8Array(getObject(arg0)); - return addHeapObject(ret); - }, arguments); + imports.wbg.__wbg_set_0ac78a2bc07da03c = function (arg0, arg1, arg2) { + getObject(arg0)[arg1 >>> 0] = takeObject(arg2); }; - imports.wbg.__wbg_length_a5587d6cd79ab197 = function () { - return logError(function (arg0) { - const ret = getObject(arg0).length; - _assertNum(ret); - return ret; - }, arguments); + imports.wbg.__wbg_isArray_38525be7442aa21e = function (arg0) { + const ret = Array.isArray(getObject(arg0)); + return ret; }; - imports.wbg.__wbg_set_dcfd613a3420f908 = function () { - return logError(function (arg0, arg1, arg2) { - getObject(arg0).set(getObject(arg1), arg2 >>> 0); - }, arguments); + imports.wbg.__wbg_instanceof_ArrayBuffer_c7cc317e5c29cc0d = function (arg0) { + let result; + try { + result = getObject(arg0) instanceof ArrayBuffer; + } catch (_) { + result = false; + } + const ret = result; + return ret; }; - imports.wbg.__wbindgen_is_function = function (arg0) { - const ret = typeof getObject(arg0) === "function"; - _assertBoolean(ret); + imports.wbg.__wbg_isSafeInteger_c38b0a16d0c7cef7 = function (arg0) { + const ret = Number.isSafeInteger(getObject(arg0)); return ret; }; - imports.wbg.__wbg_get_2aff440840bb6202 = function () { - return handleError(function (arg0, arg1) { - const ret = Reflect.get(getObject(arg0), getObject(arg1)); - return addHeapObject(ret); - }, arguments); + imports.wbg.__wbg_buffer_344d9b41efe96da7 = function (arg0) { + const ret = getObject(arg0).buffer; + return addHeapObject(ret); }; - imports.wbg.__wbg_buffer_344d9b41efe96da7 = function () { - return logError(function (arg0) { - const ret = getObject(arg0).buffer; - return addHeapObject(ret); - }, arguments); + imports.wbg.__wbg_new_d8a000788389a31e = function (arg0) { + const ret = new Uint8Array(getObject(arg0)); + return addHeapObject(ret); }; - imports.wbg.__wbindgen_debug_string = function (arg0, arg1) { - const ret = debugString(getObject(arg1)); - const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); - const len1 = WASM_VECTOR_LEN; - getInt32Memory0()[arg0 / 4 + 1] = len1; - getInt32Memory0()[arg0 / 4 + 0] = ptr1; + imports.wbg.__wbg_set_dcfd613a3420f908 = function (arg0, arg1, arg2) { + getObject(arg0).set(getObject(arg1), arg2 >>> 0); + }; + imports.wbg.__wbg_length_a5587d6cd79ab197 = function (arg0) { + const ret = getObject(arg0).length; + return ret; + }; + imports.wbg.__wbg_instanceof_Uint8Array_19e6f142a5e7e1e1 = function (arg0) { + let result; + try { + result = getObject(arg0) instanceof Uint8Array; + } catch (_) { + result = false; + } + const ret = result; + return ret; }; imports.wbg.__wbindgen_bigint_get_as_i64 = function (arg0, arg1) { const v = getObject(arg1); const ret = typeof v === "bigint" ? v : undefined; - if (!isLikeNone(ret)) { - _assertBigInt(ret); - } getBigInt64Memory0()[arg0 / 8 + 1] = isLikeNone(ret) ? BigInt(0) : ret; getInt32Memory0()[arg0 / 4 + 0] = !isLikeNone(ret); }; - imports.wbg.__wbindgen_object_drop_ref = function (arg0) { - takeObject(arg0); + imports.wbg.__wbindgen_debug_string = function (arg0, arg1) { + const ret = debugString(getObject(arg1)); + const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); + const len1 = WASM_VECTOR_LEN; + getInt32Memory0()[arg0 / 4 + 1] = len1; + getInt32Memory0()[arg0 / 4 + 0] = ptr1; }; imports.wbg.__wbindgen_throw = function (arg0, arg1) { throw new Error(getStringFromWasm0(arg0, arg1)); diff --git a/pkg/scheduler_bg.wasm b/pkg/scheduler_bg.wasm index 7a3668eb5..85f2f256c 100644 Binary files a/pkg/scheduler_bg.wasm and b/pkg/scheduler_bg.wasm differ