Streaming chunked data through readable streams


show more Streaming chunked data through readable streams provides you with in-depth training on Developer. Taught by Joseph LeBlanc as part of the Node.js Essential Training (2013) show less
please wait ...

Streaming chunked data through readable streams

Reading an entire file into memory can be troublesome, especially if the file is several gigabytes in size. A better way of handling large files is to stream the data instead. In this video we'll stream the data from a file and read individual chunks. Let's go to the exercise files. Open up chapter nine and video two, and then copy those two files to the Desktop. Now let's go to Terminal and change directory to the Desktop. It's capital D, and then press Return.

Now let's take a look at these files. I'm going to take a look at stream.js and pull it into sublime text. On line one, I'm requiring the FS Module. The FS module is a core module that deals with the file system. Then on line three, I'm calling the create read stream method of FS. I'm creating a stream out of data.json. Instead of reading all the contents of the file at once and storing it in the stream, it's creating a stream so that we can read the data one chuck at a time.

Then on line five and on line...

Streaming chunked data through readable streams
Video duration: 2m 33s 3h 17m Intermediate

Viewers:

Streaming chunked data through readable streams provides you with in-depth training on Developer. Taught by Joseph LeBlanc as part of the Node.js Essential Training (2013)

Subject:
Developer
Software:
JavaScript Node.js
Author:
please wait ...