From the course: Advanced Node.js
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Using readable streams - Node.js Tutorial
From the course: Advanced Node.js
Using readable streams
- [Instructor] In the last lesson we saw how we can create classes that extend stream dot readable to build our own readable streams. Now, sometimes you'll build your own readable streams, but most of the time you're going to use already existing stream types. You've already been doing this. Node JS comes with all types of readable streams. Http requests on the server and a response on the client, they're readable streams. The file system has readable streams. Zipping and unzipping uses readable streams. TCP sockets, process stdin, not to mention the many MPMs that implement readable streams. So let's go ahead and implement our own instance of a readable stream that already exists. We're going to go ahead and use the create readStream from the file system. So, I'm inside of an empty index dot js. You'll find this inside of your exercise files for lesson two. Lesson two, chapter three within the start folder. And I'm going to start just by requiring the fs module. So here's our file…
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.