prompt-async
The enhanced prompt
module that enables you to await
its methods.
Try it now!
Exampleprompt-async
With const prompt = ; // Available only with `prompt-async`!{ // Start the prompt. promptstart; // Get two properties from the user: the `username` and `email`. const username email = await prompt; // Get two properties from the user: the `password` and `food`. const password food = await prompt; // Log the results. console; console; console; console; console;} { try await ; catcherror console; } ;
callback hell)
The obsolete way (causes aconst prompt = ; // Still supports the obsolete way.{ // Start the prompt. promptstart; // Get two properties from the user: the `username` and `email`. prompt;} { try ; catcherror console; } ;
Frequently answered questions
prompt
. Do I have to modify the existing code to use this?
I've been working with The only thing you have to do is to replace require("prompt")
to require("prompt-async")
.
As you can see above, it has backward-compatibility, so it would work well with your prompt
code.
However, please be aware that your prompt
code pattern is discouraged, and try to use async
-await
pattern.
Any bugs, suggestions, or questions?
If you found a bug on it, or if you want to suggest something to improve it, or if you have a question,
please leave an issue on the GitHub repository or send an e-mail to me: wlzla000@naver.com
.
Feel free to contribute!
Thank you.