most-buffer
Gather most js streams events into buffers. Buffers are emitted according to a given event count or gather the complete stream if no count is given.
Installation
Using npm:
$ npm install --save most-buffer
In Node.js:
const buffer = ;
Usage
stream.thru(buffer(count)) -> Stream
stream: -a--b--c--------d--e--|
stream.thru(buffer(3)): -------[a,b,c]--------[d,e]|
count
is the size of the buffer, if undefined the full stream will be buffered before being emitted as an array.
Examples
const most = ;const buffer = ; // Logs// [1, 2, 3, 4]// [5, 6, 7, 8]// [9]most // 9 first numbers // In buffer of 4 or less
// Logs// [1, 2, 3, 4, 5, 6, 7, 8, 9]most // 9 first numbers // Buffer the complete stream