@sebastianwessel/quickjs
Version:
A typescript package to execute JavaScript and TypeScript code in a WebAssembly QuickJS sandbox
22 lines (21 loc) • 689 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadWasmModule = void 0;
const quickjs_emscripten_core_1 = require("quickjs-emscripten-core");
/**
* Loads the webassembly file and prepares sandbox creation
* @param loadOptions
* @returns
*/
const loadWasmModule = async (loadOptions) => {
try {
if (typeof loadOptions === 'string') {
return await (0, quickjs_emscripten_core_1.newQuickJSAsyncWASMModuleFromVariant)(import(loadOptions));
}
return loadOptions;
}
catch (error) {
throw new Error('Failed to load webassembly', { cause: error });
}
};
exports.loadWasmModule = loadWasmModule;