Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Node.js Basics (2014) Building a Command Line Application Getting the Response Body

David Patrick
David Patrick
1,906 Points

Why does Node Stream Chunks of Data?

In this last video it teaches you that on the data event node is emitting chunks of data from the response. What kind of benefit does this give you? I suppose you could update a progress bar? Is there any other benefits?

Thanks, David

1 Answer

It mirrors the reality that your network card / WiFi chip / etc. is getting the data in chunks as well.

What kind of benefit does this give you? I suppose you could update a progress bar? Is there any other benefits?

Some types of data can be computed upon without being completely downloaded. Like a JPEG image showing the upper portions, or streaming a movie before the whole file is complete. Things like that.