From the course: Node.js Essential Training
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
Writable file streams - Node.js Tutorial
From the course: Node.js Essential Training
Writable file streams
- [Instructor] In the last lesson, we introduced the Node.js stream interface and took a look at some readable streams. The other side of the stream coin is writeable streams. So the writeable stream is used to write the data chunks that are being read by the readable streams. So what we're going to do is improve our little ask questions app, and we'll do so first by importing, not surprisingly, our file system module. Let's also add a variable for the stream. We won't use it until our user answers the first question. So we'll say answerStream here, on line three. We'll keep our questions as is, we'll keep our empty array for our answers as is. Now, inside of our ask function, we can still use our process standard output. Let's create a once listener using process.stdin.once. We're going to listen for some data, and we'll pass that data to the callback function. So when the user answers the first question, what is your name…
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)
Listing directory files2m 25s
-
(Locked)
Reading files2m 19s
-
(Locked)
Writing and appending files3m 22s
-
(Locked)
Creating directories2m 26s
-
(Locked)
Renaming and removing files3m 29s
-
(Locked)
Renaming and removing directories3m 57s
-
(Locked)
Readable file streams5m 47s
-
(Locked)
Writable file streams4m 47s
-
(Locked)
-