mirror of
https://github.com/MercuryWorkshop/epoxy-tls.git
synced 2025-05-13 06:20:02 -04:00
headers support
This commit is contained in:
parent
59a26fd4d2
commit
81e78c89bc
5 changed files with 126 additions and 69 deletions
|
@ -1,5 +1,7 @@
|
|||
use wasm_bindgen::prelude::*;
|
||||
|
||||
use js_sys::{Array, Object};
|
||||
|
||||
pub fn set_panic_hook() {
|
||||
#[cfg(feature = "console_error_panic_hook")]
|
||||
console_error_panic_hook::set_once();
|
||||
|
@ -15,7 +17,6 @@ extern "C" {
|
|||
pub fn console_error(s: &str);
|
||||
}
|
||||
|
||||
|
||||
macro_rules! debug {
|
||||
($($t:tt)*) => (utils::console_debug(&format_args!($($t)*).to_string()))
|
||||
}
|
||||
|
@ -27,3 +28,20 @@ macro_rules! log {
|
|||
macro_rules! error {
|
||||
($($t:tt)*) => (utils::console_error(&format_args!($($t)*).to_string()))
|
||||
}
|
||||
|
||||
pub fn entries_of_object(obj: &Object) -> Vec<Vec<String>> {
|
||||
js_sys::Object::entries(obj)
|
||||
.to_vec()
|
||||
.iter()
|
||||
.map(|val| {
|
||||
Array::from(val)
|
||||
.to_vec()
|
||||
.iter()
|
||||
.map(|val| {
|
||||
val.as_string()
|
||||
.expect_throw("failed to get string from object entry")
|
||||
})
|
||||
.collect()
|
||||
})
|
||||
.collect::<Vec<Vec<_>>>()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue