jeff.hykinJ
Denoβ€’3y agoβ€’
6 replies
jeff.hykin

Deno Repl Programmatically

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)

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
Was this page helpful?