3 ms·
This looks awesome! I've already played around with pyodide and coldbrew doing the same thing for CPython. I use it for an in-memory playground [0] of an open-s
by eatonphil 5y ago
This looks awesome! I've already played around with pyodide and coldbrew doing the same thing for CPython. I use it for an in-memory playground [0] of an open-source desktop app I build [1]. I've been waiting for Ruby, Julia, and R support to add them in too.
That said, I am not seeing a link in here about how to actually use this code. Is there a good tutorial/example somewhere?
[0] app.datastation.multiprocess.io
[1] github.com/multiprocessio/datastation
- eatonphil 5y agoFound it myself [0]! :) I think. <html> <script src="https://cdn.jsdelivr.net/npm/ruby-head-wasm-wasi@latest/dist/browser.umd.js"></script> <script> const { DefaultRubyVM } = window["ruby-wasm-wasi"]; const main = async () => { // Fetch and instntiate WebAssembly binary const response = await fetch( "https://cdn.jsdelivr.net/npm/ruby-head-wasm-wasi@latest/dist/ruby.wasm" ); const buffer = await response.arrayBuffer(); const module = await WebAssembly.compile(buffer); const { vm } = await DefaultRubyVM(module); vm.printVersion(); vm.eval(` require "js" luckiness = ["Lucky", "Unlucky"].sample JS::eval("document.body.innerText = '#{luckiness}'") `); }; main(); </script> <body></body> </html> [0] https://github.com/ruby/ruby.wasm/tree/main/packages/npm-packages/ruby-head-wasm-wasi https://github.com/ruby/ruby.wasm/tree/main/packages/npm-pac...