0.0.11 • Published 6 years ago

most-limiter v0.0.11

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

most-limiter

Version License

Lossless rate limiter for most.js.

Unlike most.debounce or most.throttle, with most-limiter, each event gets through, unless the internal buffer overrides.

Installation

Using npm:

$ npm install --save most-limiter

In Node.js:

const limiter = require('most-limiter');

Usage

stream.thru(limiter(interval [, capacity = 1000])) -> Stream

stream:                    -a-b---cdef----->
stream.thru(limiter(100)): -a-b---c-d-e-f-->
  • interval is the minimum time interval between events, in ms.
  • capacity is the maximum size of the internal buffer, overrides leads to an error.
const most = require('most');
const limiter = require('most-limiter');

// Logs
// 1
// 2 (after 500ms)
// 3 (after 500ms more)
most.iterate(x => x + 1, 0)
  .take(3) // 3 first numbers
  .thru(limiter(500)) // Limit to on event every 500ms
  .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