NodeJS Prompt

Sometimes you just need a simple terminal application that requests user input. Here’s a quick way to prompt the user for input:

const readline = require("readline");
const rl = readline.createInterface(process.stdin, process.stdout);
 
rl.on("line", line => {
   console.log(`You typed ${line}`);
   rl.prompt();
});
 
rl.setPrompt("Action> ");
rl.prompt();

Comments

Popular posts from this blog

C# Record Serialization

Add timestamp to photo using ImageMagick

Read/write large blob to SQL Server from C#