ferrijs-std 0.1.0

Node and web standard library for the ferrijs QuickJS runtime: WHATWG Streams, Events, AbortController, Buffer, crypto, fs, os, url, zlib and the capability model they enforce (partly derived from awslabs/llrt, Apache-2.0).
Documentation
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
}