8000 Add example with promisified readline API · HowProgrammingWorks/CommandLine@0ad1ad2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0ad1ad2

Browse files
committed
Add example with promisified readline API
1 parent ef01058 commit 0ad1ad2

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed
File renamed without changes.
File renamed without changes.

JavaScript/2-await.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
'use strict';
2+
3+
// Node.js v17
4+
5+
const readline = require('readline').promises;
6+
7+
const rl = readline.createInterface({
8+
input: process.stdin,
9+
output: process.stdout
10+
});
11+
12+
const main = async () => {
13+
const name = await rl.question('Enter your name: ');
14+
console.log(`Hello, ${name}!`);
15+
rl.close();
16+
};
17+
18+
main();

0 commit comments

Comments
 (0)
0