pub fn get_string(obj: &JsValue, key: &str) -> Result<JsString, JsError>Expand description
Get a property as JsString. Returns Err if missing or not a string.
Returns JsString (an Rc<str>) which is cheap to clone.
ยงExample
use tsrun::{Interpreter, api, JsValue};
let mut interp = Interpreter::new();
let guard = api::create_guard(&interp);
let obj = api::create_object(&mut interp, &guard).unwrap();
api::set_property(&obj, "name", JsValue::from("Alice")).unwrap();
assert_eq!(api::get_string(&obj, "name").unwrap().as_str(), "Alice");