nodes/packages/plantarium/src/helpers.rs

16 lines
371 B
Rust
Raw Normal View History

2024-04-04 19:17:27 +02:00
use wasm_bindgen::prelude::*;
pub fn unwrap_int(val: JsValue) -> u8 {
if val.is_undefined() || val.is_null() {
panic!("Value is undefined");
}
return val.as_f64().unwrap() as u8;
}
pub fn unwrap_float(val: JsValue) -> f64 {
if val.is_undefined() || val.is_null() {
panic!("Value is undefined");
}
return val.as_f64().unwrap();
}