Quantum
How to get the path to the compiled binary?
import.meta.url
and Deno.mainModule
are used to get the current script, but after a binary is created, those get frozen to the script at the time that the compile was performed. Moving the binary somewhere else gives you the same (now wrong) result when import.meta.url
or Deno.mainModule
get called.11 replies
How do I make the crypto.subtle.digest algo flexible?
This is a learning moment, bear with me. 😅
I can hard code an algo for the digest like this:
But if I want to make the algo flexible, it forces me to make it a DigestAlgorithm and it cannot be a string shown here:
I reviewed what that is in the source:
https://github.com/denoland/deno_std/blob/main/crypto/_wasm/mod.ts
I see this:
export type DigestAlgorithm = typeof digestAlgorithms[number];
(I don't quite see what is going on here and am interested.)
Bottom line is, when I make algo:string a algo:DigestAlgorithm in the digest function param list, it stops complaining, but I need to have some calling code somewhere be a flexible string (or maybe an enum if necessary) that somehow translates to a DigestAlgorithm for this to work.
I've been struggling with this. Any ideas?26 replies
Is there a built-in parser for the string that Deno.inspect produces?
I found out in another thread that Deno.inspect(myObj) produces a visually gorgeous string representation of objects and can represent internal data structures that JSON.stringify fails to represent.
(Thank you @cknight for helping me with that!)
My next question is, does Deno happen to have the analog of JSON.parse for what gets output by Deno.inspect? Can we take the Deno.inspect output and turn it back into what would become a clone of the original object?
(To be clear: I am not asking if JSON.parse will do this. I am asking if there is a nifty Deno function that does it.)
4 replies
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].
6 replies