diff --git a/packages/wasm-bridge/src/init.ts b/packages/wasm-bridge/src/init.ts index 3b90825c..cfda1046 100644 --- a/packages/wasm-bridge/src/init.ts +++ b/packages/wasm-bridge/src/init.ts @@ -3,8 +3,6 @@ import type { InitFn, InitPromise, InitResult, WasmBaseInstance } from './types'; -import { assert } from '@polkadot/util'; - /** * @name createWasmFn * @description @@ -22,7 +20,11 @@ export function createWasmFn (root: string, wasmByt }; try { - assert(typeof WebAssembly === 'object' && typeof WebAssembly.instantiate === 'function' && wasmBytes && wasmBytes.length, 'WebAssembly is not available in your environment'); + if (!wasmBytes || !wasmBytes.length) { + throw new Error('No WebAssembly provided for initialization'); + } else if (typeof WebAssembly !== 'object' || typeof WebAssembly.instantiate !== 'function') { + throw new Error('WebAssembly is not available in your environment'); + } const source = await WebAssembly.instantiate(wasmBytes, { wbg }); @@ -30,7 +32,7 @@ export function createWasmFn (root: string, wasmByt result.type = 'wasm'; } catch (error) { // if we have a valid supplied asm.js, return that - if (asmFn) { + if (typeof asmFn === 'function') { result.wasm = asmFn(wbg); result.type = 'asm'; } else {