feat(quickjs): add console support for Array

This commit is contained in:
Christian Clason 2025-12-31 12:27:09 +01:00 committed by Christian Clason
parent a1893b4420
commit 47ae060966

View file

@ -95,10 +95,27 @@ impl Console {
Type::Module => "module".to_string(),
Type::BigInt => v.get::<String>().unwrap_or_else(|_| "BigInt".to_string()),
Type::Unknown => "unknown".to_string(),
Type::Array => {
let js_vals = v
.as_array()
.unwrap()
.iter::<Value<'_>>()
.filter_map(|x| x.ok())
.map(|x| {
if x.is_string() {
format!("'{}'", Self::format_args(&[x]))
} else {
Self::format_args(&[x])
}
})
.collect::<Vec<_>>()
.join(", ");
format!("[ {js_vals} ]")
}
Type::Symbol
| Type::Object
| Type::Proxy
| Type::Array
| Type::Function
| Type::Constructor
| Type::Promise