From 47ae0609661e2b9e531c76471f9bf6060870b207 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Wed, 31 Dec 2025 12:27:09 +0100 Subject: [PATCH] feat(quickjs): add console support for `Array` --- crates/generate/src/quickjs.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/crates/generate/src/quickjs.rs b/crates/generate/src/quickjs.rs index d02781f9..99e77397 100644 --- a/crates/generate/src/quickjs.rs +++ b/crates/generate/src/quickjs.rs @@ -95,10 +95,27 @@ impl Console { Type::Module => "module".to_string(), Type::BigInt => v.get::().unwrap_or_else(|_| "BigInt".to_string()), Type::Unknown => "unknown".to_string(), + Type::Array => { + let js_vals = v + .as_array() + .unwrap() + .iter::>() + .filter_map(|x| x.ok()) + .map(|x| { + if x.is_string() { + format!("'{}'", Self::format_args(&[x])) + } else { + Self::format_args(&[x]) + } + }) + .collect::>() + .join(", "); + + format!("[ {js_vals} ]") + } Type::Symbol | Type::Object | Type::Proxy - | Type::Array | Type::Function | Type::Constructor | Type::Promise