Spatial Efficiency

Learn spatial efficiency using a buffered API and streams.

First of all, streams allow us to do things that wouldn’t be possible by buffering data and processing it all at once. For example, consider the case in which we have to read a very big file, let’s say, in the order of hundreds of megabytes or even gigabytes. Clearly, using an API that returns a big buffer when the file is completely read is not a good idea. Imagine reading a few of these big files concurrently; our application would easily run out of memory. Besides that, buffers in V8 are limited in size. We cannot allocate more than a few gigabytes of data, so we might encounter a limitation long before running out of physical memory.

Get hands-on with 1200+ tech skills courses.