Skip to content

Latest commit

 

History

History
28 lines (22 loc) · 658 Bytes

README.md

File metadata and controls

28 lines (22 loc) · 658 Bytes

WASM dicelang

WASM-ready version of dicelang for browser usage.

Build

wasm-pack build --no-typescript --target web

Use direcly via JS

Place the .js and .wasm files in a directory (e.g. dicelang) on the web server. Then use a snippet like this to load and use:

<script type="module">
import init, { roll } from './dicelang/dicelang_wasm.js';
async function run() {
  await init();
  let {result, rolls} = roll("d20+1d4-1d6+3");
  console.log("result:", result);
  console.log("rolls:", rolls);
}
run();
</script>

Reference for the above: https://rustwasm.github.io/docs/wasm-bindgen/examples/without-a-bundler.html