rsvim_core 0.1.3-alpha.2

The core library for RSVIM text editor.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//! WASM transpiler.

pub struct Wasm;

impl Wasm {
  // Converts a wasm binary into an ES module template.
  pub fn parse(source: &str) -> String {
    format!(
      "
        const wasmCode = new Uint8Array({:?});
        const wasmModule = new WebAssembly.Module(wasmCode);
        const wasmInstance = new WebAssembly.Instance(wasmModule);
        export default wasmInstance.exports;
        ",
      source.as_bytes()
    )
  }
}