0.0.11 • Published 6 years ago

most-buffer v0.0.11

Weekly downloads
6
License
BSD-3-Clause
Repository
github
Last release
6 years ago

most-buffer

Version License

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 = require('most-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 = require('most');
const buffer = require('most-buffer');

// Logs
// [1, 2, 3, 4]
// [5, 6, 7, 8]
// [9]
most.iterate(x => x + 1, 0)
  .take(9) // 9 first numbers
  .thru(buffer(4)) // In buffer of 4 or less
  .observe(x => console.log(x))
// Logs
// [1, 2, 3, 4, 5, 6, 7, 8, 9]
most.iterate(x => x + 1, 0)
  .take(9) // 9 first numbers
  .thru(buffer()) // Buffer the complete stream
  .observe(x => console.log(x))
0.0.11

6 years ago

0.0.10

7 years ago

0.0.9

7 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago