Last active
August 3, 2021 10:33
-
-
Save Icaruk/ef7c522b5eecada17f44b68fe9b4e610 to your computer and use it in GitHub Desktop.
Node console question
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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