nodes/packages/plantarium/src/helpers.rs

27 lines
613 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();
}
2024-04-04 21:04:51 +02:00
pub fn unwrap_string(val: JsValue) -> String {
if val.is_undefined() || val.is_null() {
panic!("Value is undefined");
}
return val.as_string().unwrap();
}
2024-04-05 18:03:23 +02:00
pub fn evaluate_parameter(_val: String) -> i32 {
return 2;
2024-04-04 21:04:51 +02:00
}