Skip to content

Instantly share code, notes, and snippets.

@Icaruk
Last active August 3, 2021 10:33
Show Gist options
  • Save Icaruk/ef7c522b5eecada17f44b68fe9b4e610 to your computer and use it in GitHub Desktop.
Save Icaruk/ef7c522b5eecada17f44b68fe9b4e610 to your computer and use it in GitHub Desktop.
Node console question
const readline = require("readline");
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
async function doQuestion(question) {
const response = await new Promise( resolve => {
rl.question(question, (data) => {
resolve(data);
});
});
if (!response) return doQuestion(question);
return response;
};
const response = await doQuestion("¿?");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment