The first method to buffer data is bufferWithCount(). The bufferWithCount() method lets you specify the size of the buffer. With this method, the data will be stored in an array until the size of this array reaches the given count, upon which this array is propagated.
The bufferWithCount() method has the following signature:
The first parameter is mandatory and the second is optional:
- size: This is a number specifying the size of the buffer.
- skip: This is a number specifying how many items we should skip to create the next buffer. If not provided, it defaults to the size (this way the next buffer will contain only new elements).
Now let's see an example of this method: ...