You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.
use wasm_bindgen::prelude::*;
use serde::{Serialize, Deserialize};
use std::collections::HashMap;
use std::iter::FromIterator;
#[derive(Serialize, Deserialize)]
pub struct QueryResult {
pub data: Vec<String>
}
#[derive(Serialize, Deserialize)]
pub struct VehicleCounts {
pub data: Vec<(String, u64)>
}
#[wasm_bindgen]
pub fn get_counts(val: &JsValue) -> JsValue {
println!("here!");
let query_result: QueryResult = val.into_serde().unwrap();
let counts = get_counts_imp(query_result.data);
let vehicle_count = VehicleCounts {
data: counts
};
JsValue::from_serde(&vehicle_count).unwrap()
}
fn get_counts_imp(arr: Vec<String>) -> Vec<(String, u64)>{
let mut make_counts: HashMap<String, u64> = HashMap::new();
for vehicle in arr {
let v = make_counts.entry(vehicle).or_insert(0);
*v += 1
}
let mut hash_vec: Vec<(String, u64)> = Vec::from_iter(make_counts);
hash_vec.sort_by(|a, b| b.1.cmp(&a.1));
println!("Sorted: {:?}", hash_vec);
return hash_vec
}
Using the command
rustwasmc build --target deno
However this causes the following error in Deno
error: Uncaught TypeError: WebAssembly.Instance(): Import #0 module="__wbindgen_placeholder__" error: module is not an object or function
const wasmInstance = new WebAssembly.Instance(wasmModule, imports);
I'm trying to compile the following lib file
Using the command
However this causes the following error in Deno
It looks like the offending line is
Which is clearing the other imports added earlier in the file.
The text was updated successfully, but these errors were encountered: