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

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…

Contents