mirror of
https://github.com/bytedream/litbwraw.git
synced 2025-05-09 20:25:13 +02:00
24 lines
562 B
JavaScript
24 lines
562 B
JavaScript
async function main() {
|
|
let wasm;
|
|
for (const buildType of ['release', 'debug']) {
|
|
try {
|
|
wasm = await import(`./target/wasm32-unknown-emscripten/${buildType}/example-binary.js`);
|
|
break;
|
|
} catch (e) {
|
|
if (e.code !== 'ERR_MODULE_NOT_FOUND') throw e;
|
|
}
|
|
}
|
|
if (!wasm) {
|
|
throw new Error('Rust wasm binary not built');
|
|
}
|
|
|
|
const module = {
|
|
print: (str) => console.log(str),
|
|
printErr: (str) => console.error(str),
|
|
}
|
|
|
|
await wasm.default(module);
|
|
}
|
|
|
|
main();
|