September 2017
Intermediate to advanced
216 pages
6h 8m
English
Let's say that you have the following sequence that you need to write to a file:
const mySeq = Range(1) .filterNot(v => v % 10) .take(1000);
You want to be able to iterate over this sequence to produce a side-effect that writes each value as a line in a file. However, since this is a larger collection, you run the risk of running out of buffer space in the stream before it's flushed to the open file. This could cause errors in your application.
To cope with this situation, streams provide us with two tools. When we call write(), it will return false if the stream buffer is full. When the drain event fires, this indicates that the stream is ready to accept more write() calls. Let's create a utility function ...
Read now
Unlock full access