quickjs-jit-stdlib 0.14.1

LLRT's standard modules for quickjs-jit, vendored into one crate
Documentation
// Vendored from LLRT d9fd873e793c (libs/llrt_utils/src/string.rs); module paths and
// feature names adapted by scripts/import-stdlib.py.
use rquickjs::{Coerced, Result, Value};

#[inline]
pub fn get_string(value: &Value<'_>) -> Result<Option<String>> {
    if let Some(val) = value.as_string() {
        let string = val.to_string()?;
        return Ok(Some(string));
    }
    Ok(None)
}

pub fn get_coerced_string(value: &Value<'_>) -> Option<String> {
    if let Ok(val) = value.get::<Coerced<String>>() {
        return Some(val.0);
    };
    None
}

pub fn get_coerced_defined_string<'js>(value: &Option<Value<'js>>) -> Option<String> {
    if let Some(value) = value {
        if !value.is_undefined() {
            return get_coerced_string(value);
        }
    };
    None
}