Streams

The stream is one of the most significant module among the core modules. To define the stream in simple words, it is the flow of data received as small data chunks from a particular source. At the receiver's end, it might neither have all the stream data nor it will have to fit it memory all at once. This allows us to handle a large amount of data with limited resources. We can visualize the stream by an analogy given by Dominic Denicola. According to him:

"Streams are to asynchronous iterables as arrays are t synchronous iterables".

Consider if we need to read a large file of data in the environment where multiple read/write operations takes place. In such cases, streams provides a powerful abstraction to handle the low-level I/O system calls while still providing performance benefits.

The internal stream module should not be used directly so as to avoid the behavioral changes between Node versions. However, we can use the wrapper modules like readable-streams on the npm.

Although, streams are not extensively used in context of our book, it is one of the backbone feature of Node.js core used by its internal modules itself and has always been a big part of Node.js ecosystem. To learn more about streams follow the link: https://community.risingstack.com/the-definitive-guide-to-object-streams-in-node-js/.

Definitely make sure to check out the online docs on Node at: http://nodejs.org/api, to see the full list of modules available in Node's core and see plenty of sample code and explanations.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.205.99