mirror of
https://github.com/MercuryWorkshop/scramjet.git
synced 2025-05-14 15:00:01 -04:00
add rewrite_js_from_arraybuffer
This commit is contained in:
parent
838d4745d3
commit
7be4573d1b
2 changed files with 9 additions and 2 deletions
|
@ -11,7 +11,14 @@ extern "C" {
|
||||||
|
|
||||||
#[wasm_bindgen]
|
#[wasm_bindgen]
|
||||||
pub fn rewrite_js(js: &str) -> String {
|
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)
|
rewrite(js)
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ fn main() -> std::io::Result<()> {
|
||||||
let path = Path::new(&name);
|
let path = Path::new(&name);
|
||||||
let source_text = std::fs::read_to_string(path)?;
|
let source_text = std::fs::read_to_string(path)?;
|
||||||
|
|
||||||
println!("{}", rewrite(&source_text));
|
println!("{:#?}", rewrite(&source_text));
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue