diff --git a/rewriter/src/lib.rs b/rewriter/src/lib.rs index 2e01c9c..27c3d15 100644 --- a/rewriter/src/lib.rs +++ b/rewriter/src/lib.rs @@ -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) } diff --git a/rewriter/src/main.rs b/rewriter/src/main.rs index 61f3b00..c8e8bd9 100644 --- a/rewriter/src/main.rs +++ b/rewriter/src/main.rs @@ -25,7 +25,7 @@ fn main() -> std::io::Result<()> { let path = Path::new(&name); let source_text = std::fs::read_to_string(path)?; - println!("{}", rewrite(&source_text)); + println!("{:#?}", rewrite(&source_text)); Ok(()) }