Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@IgorDePaula
Last active February 2, 2022 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IgorDePaula/96ab21d3812a4ba8c3b1efd7e9e8fb0e to your computer and use it in GitHub Desktop.
Save IgorDePaula/96ab21d3812a4ba8c3b1efd7e9e8fb0e to your computer and use it in GitHub Desktop.
const { promisify } = require('util');
const readline = require("readline");
let rl = readline.createInterface({ input: process.stdin, output: process.stdout });
rl.question[promisify.custom] = (question) => {
return new Promise((resolve) => {
rl.question(question, resolve);
});
};
rl.questionSync = promisify(rl.question);
runAsync();
async function runAsync() {
let ans = await rl.questionSync("What is your name ?\n");
console.log(ans);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment