MCPcopy Create free account
hub / github.com/aeroxy/chrome-devtools-cli / join_console_args

Function join_console_args

src/cdp.rs:865–880  ·  view source on GitHub ↗

Helper to join console API arguments into a single string. Chrome's `Runtime.consoleAPICalled` returns arguments as an array of RemoteObjects.

(args: &[Value])

Source from the content-addressed store, hash-verified

863/// Helper to join console API arguments into a single string.
864/// Chrome's `Runtime.consoleAPICalled` returns arguments as an array of RemoteObjects.
865pub fn join_console_args(args: &[Value]) -> String {
866 args.iter()
867 .map(|arg| match arg.get("value") {
868 // String primitives: emit the raw text (no quotes).
869 Some(v) if v.is_string() => v.as_str().unwrap_or("").to_string(),
870 // Other primitives (number, bool, null): stringify directly.
871 Some(v) => v.to_string(),
872 // Objects have no `value` — fall back to their description.
873 None => arg["description"]
874 .as_str()
875 .unwrap_or("<object>")
876 .to_string(),
877 })
878 .collect::<Vec<String>>()
879 .join(" ")
880}
881
882#[cfg(test)]
883mod tests {

Callers 2

process_console_eventsFunction · 0.85
collect_sw_logsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected