nodejs / repl

REPL rewrite for Node.js ✨🐢🚀✨
MIT License
177 stars 25 forks source link

Add support for await #49

Closed zemse closed 3 years ago

zemse commented 3 years ago

This is a feature request to implement a similar existing feature In the chrome console on NodeJs REPL.

> asyncTaskThatResolvesNumber();
Promise<pending>

// chrome console
> await asyncTaskThatResolvesNumber();
123

// nodejs repl
> await asyncTaskThatResolvesNumber();
await asyncTaskThatResolvesNumber()
^^^^^

Uncaught:
SyntaxError: await is only valid in async functions and the top level bodies of modules

I think this can be very helpful for debugging or just quick trying out stuff. Current workaround I use is

> asyncTaskThatResolvesNumber().then(console.log)
devsnek commented 3 years ago

This repl already supports this. You can see the README for installation instructions.