Created
February 25, 2020 17:38
-
-
Save rmuhamedgaliev/7ee65ece4da37b8ca96be7d6ea023e9e to your computer and use it in GitHub Desktop.
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 }); | |
const getLine = (function () { | |
const getLineGen = (async function* () { | |
for await (const line of rl) { | |
yield line; | |
} | |
})(); | |
return async () => ((await getLineGen.next()).value); | |
})(); | |
const main = async () => { | |
console.log('Введите команду. Для выхода используйте команду - exit'); | |
const command = await getLine(); | |
if (command === 'exit') { | |
process.exit(0); | |
} else { | |
console.log('Неизвестная команда'); | |
} | |
main(); | |
}; | |
main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment