-
-
Save kapiljhajhria/4a18809318cca1725169a0fd6f984078 to your computer and use it in GitHub Desktop.
Simple interactive node.js script to have users continuously enter input.
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
// Taken from: | |
// http://stackoverflow.com/questions/24464404/how-to-readline-infinitely-in-node-js | |
const readline = require('readline'); | |
var log = console.log; | |
var rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}); | |
function searchPrompt() { | |
rl.question('cmd> ', input => { | |
if( input == 'exit' ) | |
return rl.close(); | |
log('You entered: ', input); | |
searchPrompt(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment