D
Deno

help

Deno Repl Programmatically

Jjeff.hykin8/14/2023
Python has a really nice not-well-known tool for creating a repl at any point in the code (kinda like a debugger but without any need for all the debugging setup). For example,
def somethin():
func = two_hour_long_computation_with_hard_to_serialze_output()
try:
a = untested_code_1(func)
b = untested_code_2(func)
c = untested_code_3(func)
except Exception as error:

#### important bit: creates a repl ####
import code; code.interact(local={**globals(),**locals()})
#### important bit ^ ####

save_results(a,b,c)
def somethin():
func = two_hour_long_computation_with_hard_to_serialze_output()
try:
a = untested_code_1(func)
b = untested_code_2(func)
c = untested_code_3(func)
except Exception as error:

#### important bit: creates a repl ####
import code; code.interact(local={**globals(),**locals()})
#### important bit ^ ####

save_results(a,b,c)
I then get a repl where I can poke around with the a, b, error vars, fix them and when I exit the repl it resumes execution (saving the output to disk so that I don't have to wait another 2 hours) Is there a way to do this in Deno? e.g. some unstable/hidden Deno.repl() I know a hacky solution could be made in userland via eval, but I wanted to check and see if there was an existing way
IioB8/14/2023
I am not aware of anything like this, though this could be an interesting feature.
NNeTT8/14/2023
Rather than "hacky", I'd say eval would be the proper way to use it.
Mmmastrac8/14/2023
It's not ideal, but you can connect devtools to your running process and insert debugger where it needs to break. The console will work like a repl. I like the idea, however!
Jjeff.hykin8/15/2023
It's hacky cause it won't have auto complete, syntax highlighting, "oh you didn't close a bracket => I'll allow multiline input", etc It could all be added with enough effort and --unstable
NNeTT8/15/2023
That's indeed true
Eexegete8/18/2023
Ruby has something similar with binding.irb (and previously binding.pry). Drops you into a REPL with debugging commands (next line, step into, step over, etc). It is hands down the best debugging experience I've ever had.

Looking for more? Join the community!

Recommended Posts
Deno for SASS dependencies?I'm trying to understand how I would migrate from Jekyll and NPM to Lume and Deno. Specifically, I uHow can I send a number across a Deno.TcpConn as stream of bytes?I need to send a number across a Deno.TcpConn as 4 bytes, so it can be read by a server as an int32.Migrating `Deno.run` to `Deno.command` with `readlines`I had the following: ```ts browserProcess = Deno.run({ cmd: buildArgs, // eg chrome exe path, thError: Not implemented: crypto.KeyObject.prototype.asymmetricKeyTypeHello. Im trying to create a RSA Keypair, using the node **crypto.generateKeyPair** function, but i `Uncaught TypeError: encode is not a function` when using npm module `@kubernetes-client/node`I'm trying to use a particular call in the npm module `@kubernetes/client-node` from deno, but I'm gLinking to external codeif i want to link to external code, do i have to import it from https://deno.land?Impossible to install Deno on Linux Ubuntu LTS (22.04) x86_64Hello Context & Tech : Trying to install Deno on Linux Ubuntu LTS v22.04 on x86_64 architecture PrGet length of video (stream. m3u8)In deno/typescript, how can i get the length of a specific video stream (m3u8)?github account blocked errori changed email my old account to another account and when i login to deno deploy with that account npm:axios not returning anythingI'm trying to troubleshoot a problem with axios (the same snippet works fine on node). I'm callingextension method returning undefined for `text/plain`Given the following: ```ts console.log( "text/plain", extension("text/plain"), extensioServing multiple static files to an HTTP requestIf a client sends a request for an array of static files names like so. ```["component01.js", "compoKv encodes integer as doubleAnyone know why Deno.kv encodes an integer in a mutli-part key as a double? ``` const key = ["int",Looking for caching API ResponsesHello there, I'm looking for a package/or examples to cache API responses for a fresh project whic