From the course: Node.js Essential Training
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Collecting information with readline - Node.js Tutorial
From the course: Node.js Essential Training
Collecting information with readline
- [Instructor] Readline is a module that allows us to ask questions of our terminal user. It's a wrapper around the standard input, standard output process that allows us to easily control the user prompt without having to work directly with stdin and stdout. So let's go ahead and create a new file here in our start folder called ask. We'll say ask.js. And here we want to first import our readline function. We'll say require readline. And then we're going to create a variable called rl, which is going to again be this wrapper around standard input and standard output in what's called an interface. So the interface has an input, which will map to process standard input. And then output is process.standard output. Then we'll call rl.question. The first thing that this will take in is a string. So we'll say how do you like Node? Then we'll add a callback function here. So we'll take in the answer. And we'll say…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Understanding core modules3m 6s
-
(Locked)
Collecting information with readline1m 38s
-
(Locked)
Using readline4m 58s
-
(Locked)
Exporting custom modules3m 17s
-
(Locked)
Creating a module3m 40s
-
(Locked)
Custom events with the EventEmitter1m 45s
-
(Locked)
Consuming a module with EventEmitter2m 22s
-
(Locked)
-
-