Function quickjs_runtime::quickjs_utils::objects::get_namespace_q

source ·
pub fn get_namespace_q(
    context: &QuickJsRealmAdapter,
    namespace: &[&str],
    create_if_absent: bool,
) -> Result<QuickJsValueAdapter, JsError>
Expand description

get a namespace object this is used to get nested object properties which are used as namespaces

§Example

use quickjs_runtime::builder::QuickJsRuntimeBuilder;
use quickjs_runtime::quickjs_utils::objects::get_namespace_q;
let rt = QuickJsRuntimeBuilder::new().build();
rt.exe_rt_task_in_event_loop(|q_js_rt| {
    let q_ctx = q_js_rt.get_main_realm();
    let ns_obj = get_namespace_q(q_ctx, &["com", "hirofa", "examplepackage"], true).ok().unwrap();
    assert!(ns_obj.is_object())
})