Skip to content

Instantly share code, notes, and snippets.

@rmuhamedgaliev
Created February 25, 2020 17:38
Show Gist options
  • Save rmuhamedgaliev/7ee65ece4da37b8ca96be7d6ea023e9e to your computer and use it in GitHub Desktop.
Save rmuhamedgaliev/7ee65ece4da37b8ca96be7d6ea023e9e to your computer and use it in GitHub Desktop.
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