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