D
Deno

help

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

QQuantum11/12/2023
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].
LLeokuma11/12/2023
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()
Ccknight11/12/2023
Try Deno.inspect(myObj) which returns a string in the same format as console.log(myObj)
LLeokuma11/12/2023
Oh I didn't know that one. Nice
QQuantum11/12/2023
Oh my goodness, that is so incredibly awesome. Thank you so much!
Jjeff.hykin11/14/2023
And if you want to make your own deno inspect use yourObj[Symbol.for("Deno.inspect")] = someFunc

Looking for more? Join the community!

Recommended 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 whenConnect to a WebSocket through a HTTP(S)/SOCKS5 proxyTitle - I am trying to connect to a `wss://` websocket through a proxy of choice at runtime. Is therExternal package code throws error: window is undefinedHello, I have imported an npm package to my project. And in this package's code, there is a conditi