Skip to content

Commit

Permalink
Use camel-case names for wasm module
Browse files Browse the repository at this point in the history
  • Loading branch information
printfn committed Nov 27, 2020
1 parent 4c76302 commit bb6a987
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
2 changes: 2 additions & 0 deletions wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name = "fend-wasm"
version = "0.1.10"
authors = ["printfn <[email protected]>"]
edition = "2018"
license = "MIT"
repository = "https://github.com/printfn/fend"

[lib]
crate-type = ["cdylib", "rlib"]
Expand Down
8 changes: 8 additions & 0 deletions wasm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ pub fn initialise() {
utils::set_panic_hook();
}

// These two functions should be merged at some point, but that would be a breaking
// API change.

#[wasm_bindgen(js_name = evaluateFendWithTimeout)]
pub fn evaluate_fend_with_timeout_2(input: &str, timeout: u32) -> String {
evaluate_fend_with_timeout(input, timeout)
}

#[wasm_bindgen]
pub fn evaluate_fend_with_timeout(input: &str, timeout: u32) -> String {
let mut ctx = fend_core::Context::new();
Expand Down
6 changes: 3 additions & 3 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ <h3 id="examples-title">examples:</h3>

let wasmInitialised = false;
async function evaluateFend(input) {
const { initialise, evaluate_fend_with_timeout } = wasm_bindgen;
const { initialise, evaluateFendWithTimeout } = wasm_bindgen;
if (!wasmInitialised) {
await wasm_bindgen('./pkg/fend_wasm_bg.wasm');
initialise();
const result = evaluate_fend_with_timeout("1 + 2", 500);
const result = evaluateFendWithTimeout("1 + 2", 500);
console.log(`1 + 2 = ${result}`);
wasmInitialised = true;
}
return evaluate_fend_with_timeout(input, 500);
return evaluateFendWithTimeout(input, 500);
}

async function update() {
Expand Down

0 comments on commit bb6a987

Please sign in to comment.