add rewrite_js_from_arraybuffer

This commit is contained in:
velzie 2024-07-16 13:21:54 -04:00
parent 838d4745d3
commit 7be4573d1b
No known key found for this signature in database
GPG key ID: 048413F95F0DDE1F
2 changed files with 9 additions and 2 deletions

View file

@ -11,7 +11,14 @@ extern "C" {
#[wasm_bindgen]
pub fn rewrite_js(js: &str) -> String {
log("hello from rust");
rewrite(js)
}
#[wasm_bindgen]
pub fn rewrite_js_from_arraybuffer(js: &[u8]) -> String {
// technically slower than the c++ string conversion but it will create *less copies*
let js = unsafe { std::str::from_utf8_unchecked(js) };
rewrite(js)
}