Quantum
Quantum9mo ago

How to get the nice Deno console.log format into a string?

When I do a console.log on an instantiated class object, I get a beautiful format in the terminal, thanks to Deno. How would I get that same nice Deno format into a string? When I do obj.toString(), I just get the standard Javascript [object Object].
5 Replies
Leokuma
Leokuma9mo ago
I'm not sure if that formatting is exposed to us. Maybe it's internal to Deno What you can do is JSON.stringify(obj). Not the same output as console.log, but better than .toString()
cknight
cknight9mo ago
Try Deno.inspect(myObj) which returns a string in the same format as console.log(myObj)
Leokuma
Leokuma9mo ago
Oh I didn't know that one. Nice
Quantum
Quantum9mo ago
Oh my goodness, that is so incredibly awesome. Thank you so much!
jeff.hykin
jeff.hykin9mo ago
And if you want to make your own deno inspect use yourObj[Symbol.for("Deno.inspect")] = someFunc
More Posts
byonm - force use of DenoWhen I use byonm enabled in my deno.json, and say I have a vite project triggered from a package.jsoCan I disable deno linting for individual files, or a path?I'm using VSCode and the Deno extension. I want to use the inbuilt functionality of VSCode for type Rust run JS/TSHow can I embed this project into a rust application so that rust can run js ts and has runtime api Set-Cookie - Header shows as "deleted"I am trying to use deno to script/scrape a website. I can successfully log in to the site (using fetI keep running into python download failed while trying to run 'cargo test' commandI am currently following the steps I. Deno's Contributing Guide and I am running cargo test but I kehow I can create an restful api with deno and firebase as database?how I can create an restful api with deno and firebase as database?How can I replace writeAllSync with the Streams API?How would one best refactor the following code to use the Web Streams API as suggested by the deprecIs possible to run nodejs (typescript) project with esm modules?I'm trying to run small nodejs project with esm modules. Simple example ```ts // foo.ts import { bAny tutorial links to help me understand the Schedule string in Deno.cron()I am currently working on an issue on the deno repo and I am trying to reconstruct the deno scheduleDeno Deploy failed:Uncaught Exception /Permission Denied : Deno.exit() is not allowedI have a college assignments that needs to be deployed using deno deploy but i get this message when