@sebastianwessel/quickjs
Version:
A typescript package to execute JavaScript and TypeScript code in a WebAssembly QuickJS sandbox
19 lines (18 loc) • 544 B
JavaScript
import { newQuickJSWASMModuleFromVariant } from 'quickjs-emscripten-core';
/**
* Loads the webassembly file and prepares sandbox creation
* @param loadOptions
* @returns
*/
export const loadWasmModule = async (loadOptions) => {
try {
if (typeof loadOptions === 'string') {
return await newQuickJSWASMModuleFromVariant(import(loadOptions));
}
return loadOptions;
}
catch (error) {
console.error(error);
throw new Error('Failed to load webassembly', { cause: error });
}
};