-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d1ef521
commit f096f6a
Showing
23 changed files
with
346 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
pub mod extract_substrs; | ||
pub mod padding; | ||
#[cfg(target_arch = "wasm32")] | ||
mod wasm; | ||
#[cfg(target_arch = "wasm32")] | ||
pub use crate::wasm::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,5 @@ | ||
use js_sys::Array; | ||
use wasm_bindgen::prelude::*; | ||
|
||
#[wasm_bindgen] | ||
pub fn pad_string(str: &str, padded_bytes_size: usize) -> Array { | ||
pub fn pad_string(str: &str, padded_bytes_size: usize) -> Vec<u8> { | ||
let mut padded_bytes = str.as_bytes().to_vec(); | ||
padded_bytes.append(&mut vec![0; padded_bytes_size - padded_bytes.len()]); | ||
|
||
let arr = Array::new_with_length(padded_bytes.len() as u32); | ||
for (i, byte) in padded_bytes.iter().enumerate() { | ||
arr.set(i as u32, JsValue::from(*byte)); | ||
} | ||
|
||
arr | ||
padded_bytes | ||
} |
Oops, something went wrong.